Skip to content

Commit

Permalink
Fixes #249 - Gitlens disappears from the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jan 17, 2018
1 parent 5682da6 commit 3409b32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

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

Expand Down
24 changes: 14 additions & 10 deletions src/currentLineController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ export class CurrentLineController extends Disposable {

if (!changed) return;

const trackCurrentLine = cfg.statusBar.enabled ||
cfg.blame.line.enabled ||
const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled ||
(this._blameAnnotationState !== undefined && this._blameAnnotationState.enabled);

if (trackCurrentLine) {
Expand Down Expand Up @@ -318,7 +317,7 @@ export class CurrentLineController extends Disposable {
}
}

this.updateStatusBar(commit);
this.updateStatusBar(commit, editor);
this.updateTrailingAnnotation(commit, blameLine, editor, line);
}

Expand Down Expand Up @@ -384,7 +383,12 @@ export class CurrentLineController extends Disposable {
}

private getBlameAnnotationState() {
return this._blameAnnotationState !== undefined ? this._blameAnnotationState : Container.config.blame.line;
if (this._blameAnnotationState !== undefined) return this._blameAnnotationState;

return {
enabled: Container.config.blame.line.enabled || Container.config.statusBar.enabled,
annotationType: Container.config.blame.line.annotationType
};
}

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

private updateStatusBar(commit: GitCommit) {
private updateStatusBar(commit: GitCommit, editor: TextEditor) {
const cfg = Container.config.statusBar;
if (!cfg.enabled || this._statusBarItem === undefined) return;
if (!cfg.enabled || this._statusBarItem === undefined || !isTextEditor(editor)) return;

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

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

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

const cfg = Container.config.annotations.line.trailing;
const decoration = Annotations.trailing(commit, cfg.format, cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat);
const cfgTrailing = Container.config.annotations.line.trailing;
const decoration = Annotations.trailing(commit, cfgTrailing.format, cfgTrailing.dateFormat === null ? Container.config.defaultDateFormat : cfgTrailing.dateFormat);
decoration.range = editor.document.validateRange(new Range(line, RangeEndOfLineIndex, line, RangeEndOfLineIndex));

editor.setDecorations(annotationDecoration, [decoration]);
Expand Down

0 comments on commit 3409b32

Please sign in to comment.