@@ -35,6 +35,7 @@ import { IntervalTimer, TimeoutTimer } from '../../../../../base/common/async.js
35
35
import { localize } from '../../../../../nls.js' ;
36
36
import { TerminalSuggestTelemetry } from './terminalSuggestTelemetry.js' ;
37
37
import { terminalSymbolAliasIcon , terminalSymbolArgumentIcon , terminalSymbolEnumMember , terminalSymbolFileIcon , terminalSymbolFlagIcon , terminalSymbolInlineSuggestionIcon , terminalSymbolMethodIcon , terminalSymbolOptionIcon , terminalSymbolFolderIcon , terminalSymbolSymbolicLinkFileIcon , terminalSymbolSymbolicLinkFolderIcon } from './terminalSymbolIcons.js' ;
38
+ import { TerminalSuggestShownTracker } from './terminalSuggestShownTracker.js' ;
38
39
39
40
export interface ISuggestController {
40
41
isPasting : boolean ;
@@ -46,9 +47,6 @@ export interface ISuggestController {
46
47
hideSuggestWidget ( cancelAnyRequests : boolean , wasClosedByUser ?: boolean ) : void ;
47
48
}
48
49
49
-
50
- let firstShownTracker : { shell : Set < TerminalShellType > ; window : boolean } | undefined = undefined ;
51
-
52
50
export function isInlineCompletionSupported ( shellType : TerminalShellType | undefined ) : boolean {
53
51
if ( ! shellType ) {
54
52
return false ;
@@ -89,6 +87,8 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
89
87
90
88
private _cancellationTokenSource : CancellationTokenSource | undefined ;
91
89
90
+ private _discoverability : TerminalSuggestShownTracker | undefined ;
91
+
92
92
isPasting : boolean = false ;
93
93
shellType : TerminalShellType | undefined ;
94
94
private readonly _shellTypeInit : Promise < void > ;
@@ -161,7 +161,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
161
161
@IConfigurationService private readonly _configurationService : IConfigurationService ,
162
162
@IInstantiationService private readonly _instantiationService : IInstantiationService ,
163
163
@IExtensionService private readonly _extensionService : IExtensionService ,
164
- @ITerminalConfigurationService private readonly _terminalConfigurationService : ITerminalConfigurationService ,
164
+ @ITerminalConfigurationService private readonly _terminalConfigurationService : ITerminalConfigurationService
165
165
) {
166
166
super ( ) ;
167
167
@@ -231,7 +231,6 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
231
231
this . _model ?. forceRefilterAll ( ) ;
232
232
}
233
233
} ) ) ;
234
- this . _register ( this . _extensionService . onWillStop ( ( ) => firstShownTracker = undefined ) ) ;
235
234
}
236
235
237
236
activate ( xterm : Terminal ) : void {
@@ -719,9 +718,9 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
719
718
// Track the time when completions are shown for the first time
720
719
if ( this . _completionRequestTimestamp !== undefined ) {
721
720
const completionLatency = Date . now ( ) - this . _completionRequestTimestamp ;
722
- if ( this . _suggestTelemetry && this . shellType ) {
723
- const firstShown = this . getFirstShown ( this . shellType ) ;
724
- this . updateShown ( ) ;
721
+ if ( this . _suggestTelemetry && this . shellType && this . _discoverability ) {
722
+ const firstShown = this . _discoverability . getFirstShown ( this . shellType ) ;
723
+ this . _discoverability . updateShown ( ) ;
725
724
this . _suggestTelemetry . logCompletionLatency ( this . _sessionId , completionLatency , firstShown ) ;
726
725
}
727
726
this . _completionRequestTimestamp = undefined ;
@@ -764,6 +763,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
764
763
} ) ) ;
765
764
}
766
765
766
+ this . _register ( this . _suggestWidget . onDidShow ( ( ) => this . _updateDiscoverabilityState ( ) ) ) ;
767
767
this . _register ( this . _suggestWidget . onDidBlurDetails ( ( e ) => {
768
768
const elt = e . relatedTarget as HTMLElement ;
769
769
if ( this . _terminal ?. element ?. contains ( elt ) ) {
@@ -779,6 +779,21 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
779
779
return this . _suggestWidget ;
780
780
}
781
781
782
+ private _updateDiscoverabilityState ( ) : void {
783
+ if ( ! this . _discoverability ) {
784
+ this . _discoverability = this . _register ( this . _instantiationService . createInstance ( TerminalSuggestShownTracker , this . shellType ) ) ;
785
+ }
786
+
787
+ if ( ! this . _suggestWidget || this . _discoverability ?. done ) {
788
+ return ;
789
+ }
790
+ this . _discoverability ?. update ( this . _suggestWidget . element . domNode ) ;
791
+ }
792
+
793
+ resetDiscoverability ( ) : void {
794
+ this . _discoverability ?. resetState ( ) ;
795
+ }
796
+
782
797
selectPreviousSuggestion ( ) : void {
783
798
this . _suggestWidget ?. selectPrevious ( ) ;
784
799
}
@@ -901,36 +916,6 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
901
916
this . _suggestWidget ?. hide ( ) ;
902
917
}
903
918
904
- getFirstShown ( shellType : TerminalShellType ) : { window : boolean ; shell : boolean } {
905
- if ( ! firstShownTracker ) {
906
- firstShownTracker = {
907
- window : true ,
908
- shell : new Set ( [ shellType ] )
909
- } ;
910
- return { window : true , shell : true } ;
911
- }
912
-
913
- const isFirstForWindow = firstShownTracker . window ;
914
- const isFirstForShell = ! firstShownTracker . shell . has ( shellType ) ;
915
-
916
- if ( isFirstForWindow || isFirstForShell ) {
917
- this . updateShown ( ) ;
918
- }
919
-
920
- return {
921
- window : isFirstForWindow ,
922
- shell : isFirstForShell
923
- } ;
924
- }
925
-
926
- updateShown ( ) : void {
927
- if ( ! this . shellType || ! firstShownTracker ) {
928
- return ;
929
- }
930
-
931
- firstShownTracker . window = false ;
932
- firstShownTracker . shell . add ( this . shellType ) ;
933
- }
934
919
}
935
920
936
921
class PersistedWidgetSize {
0 commit comments