-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
MEGA-ISSUE: Syntax highlighting in language-shellscript
#873
Comments
@Tamaranch reported that the |
The |
Some builtin commands not highlighted: Some files for comparison: https://gitlab.xfce.org/apps/mousepad/-/tree/master/tests |
Mixing single and double quotes with parameter expansion breaks highlighting in various ways. These are bashisms though, I don't think it's reproducible with POSIX parameter expansions, but it used to be supported. After this, the rest of the code is no longer highlighted: var="${var/'a'*/b}" After this everything (or almost everything) is then highlighted as strings: var="${var/'a'*/'b'}" |
I expect some of these to be bugs in |
A few bugs here! One is that the The legacy Tree-sitter grammar scopes The TextMate grammar scopes the whole thing as The new grammar scopes the whole thing as But |
@Tamaranch, how would you describe what that line of code is doing? I know a bit about parameter expansion in bash, but I'm flummoxed by that example even after messing around with it in a sample script. I ask because this is almost surely a |
Meanwhile, everything else you mentioned is addressed in this commit. I'll open a ticket against |
Replace the first occurrence of For reference, the actual lines of code I have locally are the following, but I've tried to extract the simplest example: curf="${f%'-roff2html'*}.html"
reff="${f/'-roff2html'*/'-ref'}.html" The first doesn't break highlighting, the second does. Note that in all these cases, neither single nor double quotes are necessary (double quotes might be if there was concatenation with a string containing spaces, but single quotes never are I think). |
I can confirm it's fixed, but I'm not sure if it's best to use the same color for command substitutions and strings. It makes it harder to distinguish between the command and its parameters when strings are involved, which is often the case (it seems to be theme-independent, here with One Dark): |
That's fair, but it's something that'll have to be fixed in themes. It's hard to conceive of backtick-style command substitution as a string (which it pretty much is) but |
Filed the ticket about parameter expansion as |
Addresses issue described in pulsar-edit#873 (comment)
@Tamaranch, I bumped BeforeAfterI snuck it into #906 so it'll likely make it into 1.114 in a few days. |
It may be a little better, but it's not fixed. The case I added in tree-sitter/tree-sitter-bash#242 (comment) is not fixed: reff="${f/'-roff2html'*/'-ref'}.html" It no longer breaks the highlighting in the rest of the script I have locally though, but here's another one of the same type that breaks it: manpages_path=("${manpages_path[@]/#[^'/']*/'/none'}") |
@savetheclocktower Also opening this file crashes the editor for me after this change: https://gitlab.xfce.org/apps/mousepad/-/blob/9733d85a611770c72b59c61525766187d99af0f3/tests/functions-test.sh
|
@Tamaranch The “good news” on the crash is that that file seems to come from from the I've added a comment on the |
Well, disabling the github package removes the above message, but not the crash. And the file mentioned refuses to open even though it opened correctly before. Also, enabling Legacy Tree-sitter allows it to open again. Does this file open correctly for you? |
It does, in all scenarios. That's… annoying. To be clear: this just happened for the first time when you updated to a build that you downloaded from #906's CI artifacts? I'll try some stuff tonight. If I still can't reproduce this, I'll remove that change from #906. |
Yes I was using Pulsar-1.113.2024020421.AppImage from #906 until yesterday, then I downloaded Pulsar-1.113.2024021307.AppImage (also from #906) to test the shell syntax patch, and it's with this version that the file refuses to open. |
OK. I'll test that specific build tonight and see if I can reproduce this. Thanks as always for the report. |
Sure enough! The rest of the stack trace isn't relevant; this is just the very first parsing attempt. I don't think I'd even typed anything before it gave me this error. I probably used the wrong version of Emscripten or something stupid like that. I rolled the change back in #906. @Tamaranch, my only consolation is that you've told me that this was barely a fix in the first place. At least that removes the urgency! I'll attempt this again in a few weeks. |
FWIW it looks like https://github.com/tree-sitter/tree-sitter-bash has gotten some attention over the last month or so, and at least one of the bugs I filed on that project has gotten addressed, which still seems to be present in Pulsar's version. E.g., try this: cat >x <<< 'x'
oops this line is highlighted as a string |
OK, I'll give this another shot when I get a chance. Hopefully it goes better than last time. |
@Tamaranch @danfuzz I've just updated our custom version of My best hypothesis as to why this happened is that I was generating these recent But you can try it yourself if you like by downloading a nightly build for your platform from the artifacts at the bottom of this page (once they're done building in a half-hour or so). |
I can confirm that #873 (comment) is fixed now 👍 |
IMPORTANT: Some issues have already been fixed!
If you’re still on the regular 1.113 release, you might be suffering from a problem that has already been fixed. Many fixes landed on
master
in #859. You are encouraged to download the latest rolling release — both (a) to see whether what you’re reporting has been fixed, and (b) so that you can enjoy the fixes that have been reported since the 1.113 release.This will serve as a catch-all issue for any problems you may encounter with syntax highlighting in shell scripting (
language-shellscript
). If you have problems with the new syntax highlighting (or folds, or indents) that are specific to shell scripts, keep reading.Something isn't highlighting correctly!
If there are any highlighting regressions since 1.113:
First, please scroll down and see if someone else has reported the issue. If not, please comment with
I want to go back to the old highlighting!
You can easily opt out of the new Tree-sitter highlighting for any language, but first please:
To revert to the old Tree-sitter grammar for this language only, add the following to your
config.cson
:To revert to the TextMate-style grammar for this language only, add the following to your
config.cson
:The text was updated successfully, but these errors were encountered: