Skip to content

Multi-command support for terminal suggest #241993

Closed
@mjbvz

Description

@mjbvz
Collaborator

Testing #241771

  1. On windows, try suggestions for ls && git |

bug
No suggestion show up. Works fine with just git |

Image

EDIT from @Tyriar

Second verify case:

  • Suggest on echo a ; echo in pwsh to make sure ; is handled.

Activity

meganrogge

meganrogge commented on Feb 26, 2025

@meganrogge
Contributor

A wider view of your terminal would be helpful - what shell are you using?

mjbvz

mjbvz commented on Feb 26, 2025

@mjbvz
CollaboratorAuthor

Powershell:

Image

Only the recent suggestion shows up, not the smart ones for git

meganrogge

meganrogge commented on Feb 26, 2025

@meganrogge
Contributor

If git is the first on the line, what shows up?

mjbvz

mjbvz commented on Feb 26, 2025

@mjbvz
CollaboratorAuthor

It works fine in that case, just not after any command separators

Image
added
bugIssue identified by VS Code Team member as probable bug
and removed
info-neededIssue requires more information from poster
on Feb 26, 2025
added this to the February 2025 milestone on Feb 26, 2025
Tyriar

Tyriar commented on Feb 26, 2025

@Tyriar
Member

Code pointer:

export const enum TokenType {
Command,
Argument,
}
const shellTypeResetChars: { [key: number]: string[] | undefined } = {
[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']
};
const defaultShellTypeResetChars = shellTypeResetChars[TerminalShellType.Bash]!;
export function getTokenType(ctx: { commandLine: string; cursorPosition: number }, shellType: TerminalShellType | undefined): TokenType {
const spaceIndex = ctx.commandLine.substring(0, ctx.cursorPosition).lastIndexOf(' ');
if (spaceIndex === -1) {
return TokenType.Command;
}
const previousTokens = ctx.commandLine.substring(0, spaceIndex + 1).trim();
const commandResetChars = shellType === undefined ? defaultShellTypeResetChars : shellTypeResetChars[shellType] ?? defaultShellTypeResetChars;
if (commandResetChars.some(e => previousTokens.endsWith(e))) {
return TokenType.Command;
}
return TokenType.Argument;
}

I think fig may need to get the command line starting with the second command (git of ls && git) which we might not do do currently. Let's move this out as we know support for this is very basic currently.

18 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @Tyriar@mjbvz@meganrogge

    Issue actions

      Multi-command support for terminal suggest · Issue #241993 · microsoft/vscode