diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts index 1af621de8cf1b..9c70271e2ad4f 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts @@ -322,12 +322,15 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest return; } - // Hide the widget if the cursor moves to the left of the initial position as the - // completions are no longer valid - // to do: get replacement length to be correct, readd this? - if (this._currentPromptInputState && this._currentPromptInputState.cursorIndex <= this._leadingLineContent.length) { - this.hideSuggestWidget(); - return; + // Hide the widget if the cursor moves to the left and invalidates the completions. + // Originally this was to the left of the initial position that the completions were + // requested, but since extensions are expected to allow the client-side to filter, they are + // only invalidated when whitespace is encountered. + if (this._currentPromptInputState && this._currentPromptInputState.cursorIndex < this._leadingLineContent.length) { + if (this._currentPromptInputState.cursorIndex === 0 || this._leadingLineContent[this._currentPromptInputState.cursorIndex - 1].match(/\s/)) { + this.hideSuggestWidget(); + return; + } } if (this._terminalSuggestWidgetVisibleContextKey.get()) {