@@ -23,6 +23,7 @@ export class CurrentLineController extends Disposable {
23
23
private _currentLine : number = - 1 ;
24
24
private _disposable : Disposable ;
25
25
private _editor : TextEditor | undefined ;
26
+ private _isAnnotating : boolean = false ;
26
27
private _statusBarItem : StatusBarItem | undefined ;
27
28
private _updateBlameDebounced : ( line : number , editor : TextEditor ) => Promise < void > ;
28
29
private _uri : GitUri ;
@@ -44,7 +45,7 @@ export class CurrentLineController extends Disposable {
44
45
}
45
46
46
47
dispose ( ) {
47
- this . _editor && this . _editor . setDecorations ( annotationDecoration , [ ] ) ;
48
+ this . _clearAnnotations ( this . _editor , true ) ;
48
49
49
50
this . _activeEditorLineDisposable && this . _activeEditorLineDisposable . dispose ( ) ;
50
51
this . _statusBarItem && this . _statusBarItem . dispose ( ) ;
@@ -61,9 +62,7 @@ export class CurrentLineController extends Disposable {
61
62
! Objects . areEquivalent ( cfg . annotations . line . hover , this . _config && this . _config . annotations . line . hover ) ||
62
63
! Objects . areEquivalent ( cfg . theme . annotations . line . trailing , this . _config && this . _config . theme . annotations . line . trailing ) ) {
63
64
changed = true ;
64
- if ( this . _editor ) {
65
- this . _editor . setDecorations ( annotationDecoration , [ ] ) ;
66
- }
65
+ this . _clearAnnotations ( this . _editor ) ;
67
66
}
68
67
69
68
if ( ! Objects . areEquivalent ( cfg . statusBar , this . _config && this . _config . statusBar ) ) {
@@ -117,13 +116,10 @@ export class CurrentLineController extends Disposable {
117
116
118
117
private async _onActiveTextEditorChanged ( editor : TextEditor | undefined ) {
119
118
this . _currentLine = - 1 ;
120
-
121
- const previousEditor = this . _editor ;
122
- previousEditor && previousEditor . setDecorations ( annotationDecoration , [ ] ) ;
119
+ this . _clearAnnotations ( this . _editor ) ;
123
120
124
121
if ( editor === undefined || ! this . isEditorBlameable ( editor ) ) {
125
122
this . clear ( editor ) ;
126
-
127
123
this . _editor = undefined ;
128
124
129
125
return ;
@@ -169,12 +165,14 @@ export class CurrentLineController extends Disposable {
169
165
170
166
const line = e . selections [ 0 ] . active . line ;
171
167
if ( line === this . _currentLine ) return ;
168
+
172
169
this . _currentLine = line ;
173
170
174
- if ( ! this . _uri && e . textEditor ) {
171
+ if ( ! this . _uri && e . textEditor !== undefined ) {
175
172
this . _uri = await GitUri . fromUri ( e . textEditor . document . uri , this . git ) ;
176
173
}
177
174
175
+ this . _clearAnnotations ( e . textEditor ) ;
178
176
this . _updateBlameDebounced ( line , e . textEditor ) ;
179
177
}
180
178
@@ -198,18 +196,22 @@ export class CurrentLineController extends Disposable {
198
196
}
199
197
}
200
198
201
- async clear ( editor : TextEditor | undefined , previousEditor ?: TextEditor ) {
202
- this . _clearAnnotations ( editor , previousEditor ) ;
199
+ async clear ( editor : TextEditor | undefined ) {
200
+ this . _clearAnnotations ( editor , true ) ;
203
201
this . _statusBarItem && this . _statusBarItem . hide ( ) ;
204
202
}
203
+
204
+ private async _clearAnnotations ( editor : TextEditor | undefined , force : boolean = false ) {
205
+ if ( editor === undefined || ( ! this . _isAnnotating && ! force ) ) return ;
206
+
207
+ editor . setDecorations ( annotationDecoration , [ ] ) ;
208
+ this . _isAnnotating = false ;
209
+
210
+ if ( ! force ) return ;
205
211
206
- private async _clearAnnotations ( editor : TextEditor | undefined , previousEditor ?: TextEditor ) {
207
- editor && editor . setDecorations ( annotationDecoration , [ ] ) ;
208
212
// I have no idea why the decorators sometimes don't get removed, but if they don't try again with a tiny delay
209
- if ( editor !== undefined ) {
210
- await Functions . wait ( 1 ) ;
211
- editor . setDecorations ( annotationDecoration , [ ] ) ;
212
- }
213
+ await Functions . wait ( 1 ) ;
214
+ editor . setDecorations ( annotationDecoration , [ ] ) ;
213
215
}
214
216
215
217
async show ( commit : GitCommit , blameLine : IGitCommitLine , editor : TextEditor ) {
@@ -388,6 +390,7 @@ export class CurrentLineController extends Disposable {
388
390
389
391
if ( decorationOptions . length ) {
390
392
editor . setDecorations ( annotationDecoration , decorationOptions ) ;
393
+ this . _isAnnotating = true ;
391
394
}
392
395
}
393
396
0 commit comments