mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Fixes #26 line annotation is wrong after delete
https://github.com/eamodio/vscode-gitlens/issues/26
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Objects } from './system';
|
import { Objects } from './system';
|
||||||
import { DecorationOptions, DecorationInstanceRenderOptions, DecorationRenderOptions, Disposable, ExtensionContext, Range, StatusBarAlignment, StatusBarItem, TextEditorDecorationType, TextEditor, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
|
import { DecorationOptions, DecorationInstanceRenderOptions, DecorationRenderOptions, Disposable, ExtensionContext, Range, StatusBarAlignment, StatusBarItem, TextDocumentChangeEvent, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
|
||||||
import BlameAnnotationFormatter, { BlameAnnotationFormat } from './blameAnnotationFormatter';
|
import BlameAnnotationFormatter, { BlameAnnotationFormat } from './blameAnnotationFormatter';
|
||||||
import { TextEditorComparer } from './comparers';
|
import { TextDocumentComparer, TextEditorComparer } from './comparers';
|
||||||
import { IBlameConfig, IConfig, StatusBarCommand } from './configuration';
|
import { IBlameConfig, IConfig, StatusBarCommand } from './configuration';
|
||||||
import { DocumentSchemes } from './constants';
|
import { DocumentSchemes } from './constants';
|
||||||
import GitProvider, { GitCommit, GitUri, IGitBlame, IGitCommitLine } from './gitProvider';
|
import GitProvider, { GitCommit, GitUri, IGitBlame, IGitCommitLine } from './gitProvider';
|
||||||
@@ -87,7 +87,8 @@ export default class BlameStatusBarController extends Disposable {
|
|||||||
const subscriptions: Disposable[] = [];
|
const subscriptions: Disposable[] = [];
|
||||||
|
|
||||||
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
|
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
|
||||||
subscriptions.push(window.onDidChangeTextEditorSelection(this._onActiveSelectionChanged, this));
|
subscriptions.push(window.onDidChangeTextEditorSelection(this._onEditorSelectionChanged, this));
|
||||||
|
subscriptions.push(workspace.onDidChangeTextDocument(this._onDocumentChanged, this));
|
||||||
|
|
||||||
this._activeEditorLineDisposable = Disposable.from(...subscriptions);
|
this._activeEditorLineDisposable = Disposable.from(...subscriptions);
|
||||||
}
|
}
|
||||||
@@ -132,12 +133,20 @@ export default class BlameStatusBarController extends Disposable {
|
|||||||
return await this._showBlame(e.selection.active.line, e);
|
return await this._showBlame(e.selection.active.line, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _onActiveSelectionChanged(e: TextEditorSelectionChangeEvent): Promise<void> {
|
private async _onEditorSelectionChanged(e: TextEditorSelectionChangeEvent): Promise<void> {
|
||||||
|
// Make sure this is for the editor we are tracking
|
||||||
if (!TextEditorComparer.equals(e.textEditor, this._editor)) return;
|
if (!TextEditorComparer.equals(e.textEditor, this._editor)) return;
|
||||||
|
|
||||||
return await this._showBlame(e.selections[0].active.line, e.textEditor);
|
return await this._showBlame(e.selections[0].active.line, e.textEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _onDocumentChanged(e: TextDocumentChangeEvent): Promise<void> {
|
||||||
|
// Make sure this is for the editor we are tracking
|
||||||
|
if (!this._editor || !TextDocumentComparer.equals(e.document, this._editor.document)) return;
|
||||||
|
|
||||||
|
return await this._showBlame(this._editor.selections[0].active.line, this._editor);
|
||||||
|
}
|
||||||
|
|
||||||
private async _showBlame(line: number, editor: TextEditor) {
|
private async _showBlame(line: number, editor: TextEditor) {
|
||||||
line = line - this._uri.offset;
|
line = line - this._uri.offset;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user