Browse Source

Fixes #249 - Gitlens disappears from the status bar

main
Eric Amodio 7 years ago
parent
commit
3409b3280f
2 changed files with 15 additions and 10 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +14
    -10
      src/currentLineController.ts

+ 1
- 0
CHANGELOG.md View File

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased] ## [Unreleased]
### Fixed ### 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 [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 - Fixes issue where the id (sha) was missing in the hover blame annotations for uncommitted changes

+ 14
- 10
src/currentLineController.ts View File

@ -142,8 +142,7 @@ export class CurrentLineController extends Disposable {
if (!changed) return; 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); (this._blameAnnotationState !== undefined && this._blameAnnotationState.enabled);
if (trackCurrentLine) { if (trackCurrentLine) {
@ -318,7 +317,7 @@ export class CurrentLineController extends Disposable {
} }
} }
this.updateStatusBar(commit);
this.updateStatusBar(commit, editor);
this.updateTrailingAnnotation(commit, blameLine, editor, line); this.updateTrailingAnnotation(commit, blameLine, editor, line);
} }
@ -384,7 +383,12 @@ export class CurrentLineController extends Disposable {
} }
private getBlameAnnotationState() { 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; private _updateBlameDebounced: ((line: number, editor: TextEditor, trackedDocument: TrackedDocument<GitDocumentState>) => void) & IDeferrable;
@ -489,9 +493,9 @@ export class CurrentLineController extends Disposable {
this.clear(editor); this.clear(editor);
} }
private updateStatusBar(commit: GitCommit) {
private updateStatusBar(commit: GitCommit, editor: TextEditor) {
const cfg = Container.config.statusBar; 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, { this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, {
truncateMessageAtNewLine: true, truncateMessageAtNewLine: true,
@ -531,13 +535,13 @@ export class CurrentLineController extends Disposable {
} }
private async updateTrailingAnnotation(commit: GitCommit, blameLine: GitCommitLine, editor: TextEditor, line?: number) { 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; 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)); decoration.range = editor.document.validateRange(new Range(line, RangeEndOfLineIndex, line, RangeEndOfLineIndex));
editor.setDecorations(annotationDecoration, [decoration]); editor.setDecorations(annotationDecoration, [decoration]);

Loading…
Cancel
Save