Skip to content

Commit 81989af

Browse files
authored
ensure there's a space before reset char (microsoft#253925)
fix microsoft#253190
1 parent 51aa46f commit 81989af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extensions/terminal-suggest/src/tokens.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const enum TokenType {
1414
export const shellTypeResetChars = new Map<TerminalShellType, string[]>([
1515
[TerminalShellType.Bash, ['>', '>>', '<', '2>', '2>>', '&>', '&>>', '|', '|&', '&&', '||', '&', ';', '(', '{', '<<']],
1616
[TerminalShellType.Zsh, ['>', '>>', '<', '2>', '2>>', '&>', '&>>', '<>', '|', '|&', '&&', '||', '&', ';', '(', '{', '<<', '<<<', '<(']],
17-
[TerminalShellType.PowerShell, ['>', '>>', '<', '2>', '2>>', '*>', '*>>', '|', ';', '-and', '-or', '-not', '!', '&', '-eq', '-ne', '-gt', '-lt', '-ge', '-le', '-like', '-notlike', '-match', '-notmatch', '-contains', '-notcontains', '-in', '-notin']]
17+
[TerminalShellType.PowerShell, ['>', '>>', '<', '2>', '2>>', '*>', '*>>', '|', ';', ' -and ', ' -or ', ' -not ', '!', '&', ' -eq ', ' -ne ', ' -gt ', ' -lt ', ' -ge ', ' -le ', ' -like ', ' -notlike ', ' -match ', ' -notmatch ', ' -contains ', ' -notcontains ', ' -in ', ' -notin ']]
1818
]);
1919

2020
export const defaultShellTypeResetChars = shellTypeResetChars.get(TerminalShellType.Bash)!;
@@ -31,7 +31,7 @@ export function getTokenType(ctx: { commandLine: string; cursorPosition: number
3131

3232
// Look for " <reset char> " before the word
3333
for (const resetChar of commandResetChars) {
34-
const pattern = ` ${resetChar} `;
34+
const pattern = shellType === TerminalShellType.PowerShell ? `${resetChar}` : ` ${resetChar} `;
3535
if (beforeWord.endsWith(pattern)) {
3636
return TokenType.Command;
3737
}

0 commit comments

Comments
 (0)