Skip to content

Commit 3409b32

Browse files
committed
Fixes #249 - Gitlens disappears from the status bar
1 parent 5682da6 commit 3409b32

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88
### Fixed
9+
- Fixes [#249](https://github.com/eamodio/vscode-gitlens/issues/249) - Gitlens disappears from the status bar
910
- Fixes issue where [Gravatars](https://en.gravatar.com/) in the gutter blame annotations weren't restored on tab switch
1011
- Fixes issue where the id (sha) was missing in the hover blame annotations for uncommitted changes
1112

src/currentLineController.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ export class CurrentLineController extends Disposable {
142142

143143
if (!changed) return;
144144

145-
const trackCurrentLine = cfg.statusBar.enabled ||
146-
cfg.blame.line.enabled ||
145+
const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled ||
147146
(this._blameAnnotationState !== undefined && this._blameAnnotationState.enabled);
148147

149148
if (trackCurrentLine) {
@@ -318,7 +317,7 @@ export class CurrentLineController extends Disposable {
318317
}
319318
}
320319

321-
this.updateStatusBar(commit);
320+
this.updateStatusBar(commit, editor);
322321
this.updateTrailingAnnotation(commit, blameLine, editor, line);
323322
}
324323

@@ -384,7 +383,12 @@ export class CurrentLineController extends Disposable {
384383
}
385384

386385
private getBlameAnnotationState() {
387-
return this._blameAnnotationState !== undefined ? this._blameAnnotationState : Container.config.blame.line;
386+
if (this._blameAnnotationState !== undefined) return this._blameAnnotationState;
387+
388+
return {
389+
enabled: Container.config.blame.line.enabled || Container.config.statusBar.enabled,
390+
annotationType: Container.config.blame.line.annotationType
391+
};
388392
}
389393

390394
private _updateBlameDebounced: ((line: number, editor: TextEditor, trackedDocument: TrackedDocument<GitDocumentState>) => void) & IDeferrable;
@@ -489,9 +493,9 @@ export class CurrentLineController extends Disposable {
489493
this.clear(editor);
490494
}
491495

492-
private updateStatusBar(commit: GitCommit) {
496+
private updateStatusBar(commit: GitCommit, editor: TextEditor) {
493497
const cfg = Container.config.statusBar;
494-
if (!cfg.enabled || this._statusBarItem === undefined) return;
498+
if (!cfg.enabled || this._statusBarItem === undefined || !isTextEditor(editor)) return;
495499

496500
this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, {
497501
truncateMessageAtNewLine: true,
@@ -531,13 +535,13 @@ export class CurrentLineController extends Disposable {
531535
}
532536

533537
private async updateTrailingAnnotation(commit: GitCommit, blameLine: GitCommitLine, editor: TextEditor, line?: number) {
534-
const state = this.getBlameAnnotationState();
535-
if (!state.enabled || state.annotationType !== LineAnnotationType.Trailing || !isTextEditor(editor)) return;
538+
const cfg = Container.config.blame.line;
539+
if (!cfg.enabled || cfg.annotationType !== LineAnnotationType.Trailing || !isTextEditor(editor)) return;
536540

537541
line = line === undefined ? blameLine.line : line;
538542

539-
const cfg = Container.config.annotations.line.trailing;
540-
const decoration = Annotations.trailing(commit, cfg.format, cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat);
543+
const cfgTrailing = Container.config.annotations.line.trailing;
544+
const decoration = Annotations.trailing(commit, cfgTrailing.format, cfgTrailing.dateFormat === null ? Container.config.defaultDateFormat : cfgTrailing.dateFormat);
541545
decoration.range = editor.document.validateRange(new Range(line, RangeEndOfLineIndex, line, RangeEndOfLineIndex));
542546

543547
editor.setDecorations(annotationDecoration, [decoration]);

0 commit comments

Comments
 (0)