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

shellsession language not highlighting first command #616

Closed
4 of 5 tasks
sventec opened this issue Mar 8, 2024 · 5 comments
Closed
4 of 5 tasks

shellsession language not highlighting first command #616

sventec opened this issue Mar 8, 2024 · 5 comments
Labels

Comments

@sventec
Copy link

sventec commented Mar 8, 2024

Validations

Describe the bug

When using the syntax highlighter shellsession, the first bash command on the line is inconsistently formatted, compared to subsequent commands. This can be seen directly in the Playground by using a command such as:

user@test$ echo -n $EDITOR | grep -E "vim"

As seen in this screenshot, grep and -E are stylized, while cat and -n are not:
image

Here is another example with ; instead of |:
image

Reproduction

Type a compound command with e.g. | or ; using the shellsession language in the Playground

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@sventec sventec changed the title shellsession highlighting not highlighting first command shellsession language not highlighting first command Mar 8, 2024
@sventec
Copy link
Author

sventec commented Mar 8, 2024

For more context, here is the Playground highlighting the examples from above using the shell grammar. This is what seems to be referenced in tm-grammars as the grammar to use for everything after the $ in shellsession.

image

As can be seen, the syntax highlighting doesn't match with the highlighting after $ in shellsession.

@Robot-Inventor
Copy link

Robot-Inventor commented Mar 11, 2024

I have the same issue. Using console.log() to output token in tokenizeWithTheme() function, I found that the code was not tokenized correctly. I'm not familiar with this project, but it seems like a bug in the grammar file or its loading process or vscode-textmate.

{ content: 'user@test$', offset: 0, color: '#569CD6', fontStyle: 0 }
{ content: ' echo -n ', offset: 10, color: '#CCCCCC', fontStyle: 0 }
{ content: '$EDITOR', offset: 19, color: '#9CDCFE', fontStyle: 0 }
{ content: ' ', offset: 26, color: '#CCCCCC', fontStyle: 0 }
{ content: '|', offset: 27, color: '#D4D4D4', fontStyle: 0 }
{ content: ' ', offset: 28, color: '#CCCCCC', fontStyle: 0 }
{ content: 'grep', offset: 29, color: '#DCDCAA', fontStyle: 0 }
{ content: ' ', offset: 33, color: '#CCCCCC', fontStyle: 0 }
{ content: '-E', offset: 34, color: '#569CD6', fontStyle: 0 }
{ content: ' ', offset: 36, color: '#CCCCCC', fontStyle: 0 }
{ content: '"vim"', offset: 37, color: '#CE9178', fontStyle: 0 }

@Robot-Inventor
Copy link

When I loaded the shellsession grammar file into VS Code, the same problem occurred. Therefore, it is even more likely that either the grammar file or vscode-textmate is the cause of this problem.

image

@Robot-Inventor
Copy link

Robot-Inventor commented Mar 11, 2024

Upon further inspection, echo -n is correctly recognized as source.shell, so the shellsession grammar file seems to be correct. Perhaps this is a bug in vscode-textmate or shellscript grammer file? (Sorry if I'm thinking wrong)

image

@antfu
Copy link
Member

antfu commented Mar 11, 2024

Thanks for investigating @Robot-Inventor! In that case it's a grammar issue but not Shiki's, please report upstream. Once it get fixed upstream, Shiki will sync them back automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants