Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add very basic tokenizer for command line #239344

Merged
merged 2 commits into from
Jan 31, 2025
Merged

Add very basic tokenizer for command line #239344

merged 2 commits into from
Jan 31, 2025

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Jan 31, 2025

Fixes #239018

Issue example:

image

@Tyriar Tyriar added this to the February 2025 milestone Jan 31, 2025
@Tyriar Tyriar requested a review from meganrogge January 31, 2025 16:32
@Tyriar Tyriar self-assigned this Jan 31, 2025
@Tyriar Tyriar enabled auto-merge January 31, 2025 16:32
if (spaceIndex === -1) {
return TokenType.Command;
}
const tokenIndex = spaceIndex === -1 ? 0 : spaceIndex + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc we return when spaceIndex === -1 above this, I think we can just set this to spaceIndex + 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

if (spaceIndex === -1) {
return TokenType.Command;
}
const tokenIndex = spaceIndex === -1 ? 0 : spaceIndex + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tokenIndex = spaceIndex === -1 ? 0 : spaceIndex + 1;
const tokenIndex = spaceIndex + 1;

return TokenType.Command;
}
const tokenIndex = spaceIndex === -1 ? 0 : spaceIndex + 1;
const previousTokens = ctx.commandLine.substring(0, tokenIndex).trim();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename priorCommandFragment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to lean into the "token" wording here since chances are as we improve this we'll turn closer and closer into a real lexer and understand more of the tokens.

Copy link
Contributor

@meganrogge meganrogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼

@Tyriar Tyriar merged commit e7415f5 into main Jan 31, 2025
8 checks passed
@Tyriar Tyriar deleted the tyriar/239018 branch January 31, 2025 21:20
Tyriar added a commit that referenced this pull request Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filepaths suggested in non-applicable locations, does not have support for running multiple commands on a line
2 participants