@@ -72,7 +72,7 @@ export interface ITerminalCompletionService {
72
72
_serviceBrand : undefined ;
73
73
readonly providers : IterableIterator < ITerminalCompletionProvider > ;
74
74
registerTerminalCompletionProvider ( extensionIdentifier : string , id : string , provider : ITerminalCompletionProvider , ...triggerCharacters : string [ ] ) : IDisposable ;
75
- provideCompletions ( promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , shellType : TerminalShellType , capabilities : ITerminalCapabilityStore , token : CancellationToken , triggerCharacter ?: boolean , skipExtensionCompletions ?: boolean ) : Promise < ITerminalCompletion [ ] | undefined > ;
75
+ provideCompletions ( promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , shellType : TerminalShellType , capabilities : ITerminalCapabilityStore , token : CancellationToken , triggerCharacter ?: boolean , skipExtensionCompletions ?: boolean , explicitlyInvoked ?: boolean ) : Promise < ITerminalCompletion [ ] | undefined > ;
76
76
}
77
77
78
78
export class TerminalCompletionService extends Disposable implements ITerminalCompletionService {
@@ -122,7 +122,7 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
122
122
} ) ;
123
123
}
124
124
125
- async provideCompletions ( promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , shellType : TerminalShellType , capabilities : ITerminalCapabilityStore , token : CancellationToken , triggerCharacter ?: boolean , skipExtensionCompletions ?: boolean ) : Promise < ITerminalCompletion [ ] | undefined > {
125
+ async provideCompletions ( promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , shellType : TerminalShellType , capabilities : ITerminalCapabilityStore , token : CancellationToken , triggerCharacter ?: boolean , skipExtensionCompletions ?: boolean , explicitlyInvoked ?: boolean ) : Promise < ITerminalCompletion [ ] | undefined > {
126
126
if ( ! this . _providers || ! this . _providers . values || cursorPosition < 0 ) {
127
127
return undefined ;
128
128
}
@@ -148,7 +148,7 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
148
148
149
149
if ( skipExtensionCompletions ) {
150
150
providers = providers . filter ( p => p . isBuiltin ) ;
151
- return this . _collectCompletions ( providers , shellType , promptValue , cursorPosition , allowFallbackCompletions , capabilities , token ) ;
151
+ return this . _collectCompletions ( providers , shellType , promptValue , cursorPosition , allowFallbackCompletions , capabilities , token , explicitlyInvoked ) ;
152
152
}
153
153
154
154
const providerConfig : { [ key : string ] : boolean } = this . _configurationService . getValue ( TerminalSuggestSettingId . Providers ) ;
@@ -161,17 +161,18 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
161
161
return ;
162
162
}
163
163
164
- return this . _collectCompletions ( providers , shellType , promptValue , cursorPosition , allowFallbackCompletions , capabilities , token ) ;
164
+ return this . _collectCompletions ( providers , shellType , promptValue , cursorPosition , allowFallbackCompletions , capabilities , token , explicitlyInvoked ) ;
165
165
}
166
166
167
- private async _collectCompletions ( providers : ITerminalCompletionProvider [ ] , shellType : TerminalShellType , promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , capabilities : ITerminalCapabilityStore , token : CancellationToken ) : Promise < ITerminalCompletion [ ] | undefined > {
167
+ private async _collectCompletions ( providers : ITerminalCompletionProvider [ ] , shellType : TerminalShellType , promptValue : string , cursorPosition : number , allowFallbackCompletions : boolean , capabilities : ITerminalCapabilityStore , token : CancellationToken , explicitlyInvoked ?: boolean ) : Promise < ITerminalCompletion [ ] | undefined > {
168
168
const completionPromises = providers . map ( async provider => {
169
169
if ( provider . shellTypes && ! provider . shellTypes . includes ( shellType ) ) {
170
170
return undefined ;
171
171
}
172
+ const timeoutMs = explicitlyInvoked ? 30000 : 5000 ;
172
173
const completions = await Promise . race ( [
173
174
provider . provideCompletions ( promptValue , cursorPosition , allowFallbackCompletions , token ) ,
174
- timeout ( 5000 )
175
+ timeout ( timeoutMs )
175
176
] ) ;
176
177
if ( ! completions ) {
177
178
return undefined ;
0 commit comments