Use terminal suggest trigger chars even when widget is visible

Fixes #222187
This commit is contained in:
Daniel Imms
2024-07-19 07:10:02 -07:00
parent 9b7b416241
commit 2c265b30f3
@@ -184,12 +184,11 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
private _sync(promptInputState: IPromptInputModelState): void {
const config = this._configurationService.getValue<ITerminalSuggestConfiguration>(terminalSuggestConfigSection);
if (!this._terminalSuggestWidgetVisibleContextKey.get()) {
// If input has been added
if (!this._mostRecentPromptInputState || promptInputState.cursorIndex > this._mostRecentPromptInputState.cursorIndex) {
let sent = false;
// Quick suggestions
// If input has been added
let sent = false;
if (!this._mostRecentPromptInputState || promptInputState.cursorIndex > this._mostRecentPromptInputState.cursorIndex) {
// Quick suggestions
if (!this._terminalSuggestWidgetVisibleContextKey.get()) {
if (config.quickSuggestions) {
const completionPrefix = promptInputState.value.substring(0, promptInputState.cursorIndex);
if (promptInputState.cursorIndex === 1 || completionPrefix.match(/([\s\[])[^\s]$/)) {
@@ -201,14 +200,14 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
}
}
}
}
// Trigger characters
if (config.suggestOnTriggerCharacters && !sent) {
const lastChar = promptInputState.value.at(promptInputState.cursorIndex - 1);
if (lastChar?.match(/[\\\/\-]/)) {
this._requestCompletions();
sent = true;
}
// Trigger characters - this happens even if the widget is showing
if (config.suggestOnTriggerCharacters && !sent) {
const lastChar = promptInputState.value.at(promptInputState.cursorIndex - 1);
if (lastChar?.match(/[\\\/\-]/)) {
this._requestCompletions();
sent = true;
}
}
}