3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
+ import { TimeoutTimer } from '../../../../../base/common/async.js' ;
6
7
import { Disposable , IDisposable } from '../../../../../base/common/lifecycle.js' ;
7
8
import { IStorageService , StorageScope , StorageTarget } from '../../../../../platform/storage/common/storage.js' ;
8
9
import { TerminalShellType } from '../../../../../platform/terminal/common/terminal.js' ;
@@ -23,7 +24,7 @@ interface ITerminalSuggestShownTracker extends IDisposable {
23
24
export class TerminalSuggestShownTracker extends Disposable implements ITerminalSuggestShownTracker {
24
25
private _done : boolean ;
25
26
private _count : number ;
26
- private _timeout : Timeout | undefined ;
27
+ private _timeout : TimeoutTimer | undefined ;
27
28
private _start : number | undefined ;
28
29
29
30
private _firstShownTracker : { shell : Set < TerminalShellType > ; window : boolean } | undefined = undefined ;
@@ -51,6 +52,14 @@ export class TerminalSuggestShownTracker extends Disposable implements ITerminal
51
52
this . _firstShownTracker = undefined ;
52
53
}
53
54
55
+ resetTimer ( ) : void {
56
+ if ( this . _timeout ) {
57
+ this . _timeout . cancel ( ) ;
58
+ this . _timeout = undefined ;
59
+ }
60
+ this . _start = undefined ;
61
+ }
62
+
54
63
update ( widgetElt : HTMLElement | undefined ) : void {
55
64
if ( this . _done ) {
56
65
return ;
@@ -63,10 +72,11 @@ export class TerminalSuggestShownTracker extends Disposable implements ITerminal
63
72
if ( this . _count >= TERMINAL_SUGGEST_DISCOVERABILITY_MAX_COUNT ) {
64
73
this . _setDone ( widgetElt ) ;
65
74
} else if ( ! this . _start ) {
75
+ this . resetTimer ( ) ;
66
76
this . _start = Date . now ( ) ;
67
- this . _timeout = setTimeout ( ( ) => {
77
+ this . _timeout = this . _register ( new TimeoutTimer ( ( ) => {
68
78
this . _setDone ( widgetElt ) ;
69
- } , TERMINAL_SUGGEST_DISCOVERABILITY_MIN_MS ) ;
79
+ } , TERMINAL_SUGGEST_DISCOVERABILITY_MIN_MS ) ) ;
70
80
}
71
81
}
72
82
@@ -77,7 +87,7 @@ export class TerminalSuggestShownTracker extends Disposable implements ITerminal
77
87
widgetElt . classList . remove ( 'increased-discoverability' ) ;
78
88
}
79
89
if ( this . _timeout ) {
80
- clearTimeout ( this . _timeout ) ;
90
+ this . _timeout . cancel ( ) ;
81
91
this . _timeout = undefined ;
82
92
}
83
93
this . _start = undefined ;
0 commit comments