diff --git a/extensions/terminal-suggest/src/tokens.ts b/extensions/terminal-suggest/src/tokens.ts index ee39314b6f9..cadab15ba64 100644 --- a/extensions/terminal-suggest/src/tokens.ts +++ b/extensions/terminal-suggest/src/tokens.ts @@ -14,7 +14,7 @@ export const enum TokenType { export const shellTypeResetChars = new Map([ [TerminalShellType.Bash, ['>', '>>', '<', '2>', '2>>', '&>', '&>>', '|', '|&', '&&', '||', '&', ';', '(', '{', '<<']], [TerminalShellType.Zsh, ['>', '>>', '<', '2>', '2>>', '&>', '&>>', '<>', '|', '|&', '&&', '||', '&', ';', '(', '{', '<<', '<<<', '<(']], - [TerminalShellType.PowerShell, ['>', '>>', '<', '2>', '2>>', '*>', '*>>', '|', ';', '-and', '-or', '-not', '!', '&', '-eq', '-ne', '-gt', '-lt', '-ge', '-le', '-like', '-notlike', '-match', '-notmatch', '-contains', '-notcontains', '-in', '-notin']] + [TerminalShellType.PowerShell, ['>', '>>', '<', '2>', '2>>', '*>', '*>>', '|', ';', ' -and ', ' -or ', ' -not ', '!', '&', ' -eq ', ' -ne ', ' -gt ', ' -lt ', ' -ge ', ' -le ', ' -like ', ' -notlike ', ' -match ', ' -notmatch ', ' -contains ', ' -notcontains ', ' -in ', ' -notin ']] ]); export const defaultShellTypeResetChars = shellTypeResetChars.get(TerminalShellType.Bash)!; @@ -31,7 +31,7 @@ export function getTokenType(ctx: { commandLine: string; cursorPosition: number // Look for " " before the word for (const resetChar of commandResetChars) { - const pattern = ` ${resetChar} `; + const pattern = shellType === TerminalShellType.PowerShell ? `${resetChar}` : ` ${resetChar} `; if (beforeWord.endsWith(pattern)) { return TokenType.Command; }