diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts index 82b9dc7d514..96676a5a12c 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminal.suggest.contribution.ts @@ -192,7 +192,7 @@ registerActiveInstanceAction({ weight: KeybindingWeight.WorkbenchContrib + 1, when: ContextKeyExpr.and(TerminalContextKeys.focus, TerminalContextKeys.terminalShellIntegrationEnabled, ContextKeyExpr.equals(`config.${TerminalSuggestSettingId.Enabled}`, true)) }, - run: (activeInstance) => TerminalSuggestContribution.get(activeInstance)?.addon?.requestCompletions() + run: (activeInstance) => TerminalSuggestContribution.get(activeInstance)?.addon?.requestCompletions(true) }); registerActiveInstanceAction({ diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts index 331d36a2e58..9f173cfc15a 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts @@ -129,7 +129,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest })); } - private async _handleCompletionProviders(terminal: Terminal | undefined, token: CancellationToken, triggerCharacter?: boolean): Promise { + private async _handleCompletionProviders(terminal: Terminal | undefined, token: CancellationToken, explicitlyInvoked?: boolean): Promise { // Nothing to handle if the terminal is not attached if (!terminal?.element || !this._enableWidget || !this._promptInputModel) { return; @@ -156,7 +156,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest await this._extensionService.activateByEvent('onTerminalCompletionsRequested'); } - const providedCompletions = await this._terminalCompletionService.provideCompletions(this._promptInputModel.prefix, this._promptInputModel.cursorIndex, this._shellType, token, triggerCharacter, doNotRequestExtensionCompletions); + const providedCompletions = await this._terminalCompletionService.provideCompletions(this._promptInputModel.prefix, this._promptInputModel.cursorIndex, this._shellType, token, doNotRequestExtensionCompletions); if (!providedCompletions?.length || token.isCancellationRequested) { return; } @@ -220,7 +220,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest if (token.isCancellationRequested) { return; } - this._showCompletions(model); + this._showCompletions(model, explicitlyInvoked); } setContainerWithOverflow(container: HTMLElement): void { @@ -231,7 +231,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest this._screen = screen; } - async requestCompletions(triggerCharacter?: boolean): Promise { + async requestCompletions(explicitlyInvoked?: boolean): Promise { if (!this._promptInputModel) { return; } @@ -245,7 +245,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest } this._cancellationTokenSource = new CancellationTokenSource(); const token = this._cancellationTokenSource.token; - await this._handleCompletionProviders(this._terminal, token, triggerCharacter); + await this._handleCompletionProviders(this._terminal, token, explicitlyInvoked); } private _sync(promptInputState: IPromptInputModelState): void { @@ -292,7 +292,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest } for (const char of provider.triggerCharacters) { if (prefix?.endsWith(char)) { - this.requestCompletions(true); + this.requestCompletions(); sent = true; break; } @@ -359,13 +359,13 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest }; } - private _showCompletions(model: SimpleCompletionModel): void { + private _showCompletions(model: SimpleCompletionModel, explicitlyInvoked?: boolean): void { if (!this._terminal?.element) { return; } const suggestWidget = this._ensureSuggestWidget(this._terminal); suggestWidget.setCompletionModel(model); - if (!this._promptInputModel) { + if (!this._promptInputModel || !explicitlyInvoked && model.items.length === 0) { return; } this._model = model;