@@ -13,15 +13,12 @@ export class OvertypingCapturer implements IDisposable {
13
13
private readonly _disposables = new DisposableStore ( ) ;
14
14
15
15
private _lastOvertyped : { value : string ; multiline : boolean } [ ] = [ ] ;
16
- private _empty : boolean = true ;
16
+ private _locked : boolean = false ;
17
17
18
18
constructor ( editor : ICodeEditor , suggestModel : SuggestModel ) {
19
19
20
20
this . _disposables . add ( editor . onWillType ( ( ) => {
21
- if ( ! this . _empty ) {
22
- return ;
23
- }
24
- if ( ! editor . hasModel ( ) ) {
21
+ if ( this . _locked || ! editor . hasModel ( ) ) {
25
22
return ;
26
23
}
27
24
@@ -37,6 +34,9 @@ export class OvertypingCapturer implements IDisposable {
37
34
}
38
35
}
39
36
if ( ! willOvertype ) {
37
+ if ( this . _lastOvertyped . length !== 0 ) {
38
+ this . _lastOvertyped . length = 0 ;
39
+ }
40
40
return ;
41
41
}
42
42
@@ -50,18 +50,19 @@ export class OvertypingCapturer implements IDisposable {
50
50
}
51
51
this . _lastOvertyped [ i ] = { value : model . getValueInRange ( selection ) , multiline : selection . startLineNumber !== selection . endLineNumber } ;
52
52
}
53
- this . _empty = false ;
53
+ } ) ) ;
54
+
55
+ this . _disposables . add ( suggestModel . onDidTrigger ( e => {
56
+ this . _locked = true ;
54
57
} ) ) ;
55
58
56
59
this . _disposables . add ( suggestModel . onDidCancel ( e => {
57
- if ( ! this . _empty && ! e . retrigger ) {
58
- this . _empty = true ;
59
- }
60
+ this . _locked = false ;
60
61
} ) ) ;
61
62
}
62
63
63
64
getLastOvertypedInfo ( idx : number ) : { value : string ; multiline : boolean } | undefined {
64
- if ( ! this . _empty && idx >= 0 && idx < this . _lastOvertyped . length ) {
65
+ if ( idx >= 0 && idx < this . _lastOvertyped . length ) {
65
66
return this . _lastOvertyped [ idx ] ;
66
67
}
67
68
return undefined ;
0 commit comments