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

Nested square brackets for dictionaries cause problems #74

Open
alexr00 opened this issue Jan 17, 2024 · 2 comments
Open

Nested square brackets for dictionaries cause problems #74

alexr00 opened this issue Jan 17, 2024 · 2 comments

Comments

@alexr00
Copy link

alexr00 commented Jan 17, 2024

The code with a problem is:

#!/bin/bash
declare -A a=();
a["[]"]=x;
b=${a["[]"]}; # this is incorrectly highlighted as part of a string
echo ${b}; # this too, it only ends after this double quote: " (this is highlighted as script)

It looks like:

image

It should look like:

image

Some notes about what the scopes are:

b=${a["[]"]};

b=${a scopes all appear to be ok
[ Also seems to be ok

punctuation.section.array.shell
meta.parameter-expansion
meta.expression.assignment.shell
meta.statement.shell
source.shell

"[ I would expect the " to start a string here

meta.parameter-expansion
meta.expression.assignment.shell
meta.statement.shell
source.shell

] this also should be part of a string

punctuation.section.array.shell
meta.parameter-expansion
meta.expression.assignment.shell
meta.statement.shell
source.shell

" Now a string is started, but really it should be ended

punctuation.definition.string.begin.shell
string.quoted.double.shell
meta.parameter-expansion
meta.expression.assignment.shell
meta.statement.shell
source.shell

Originally from @SkyLined in microsoft/vscode#202566

@jeff-hykin
Copy link
Owner

Situation was improved, no longer a cascading breakage. It was fixed on an earlier version, but is at least fixed on v1.8.5

@jeff-hykin
Copy link
Owner

(didn't mean to close), nested brackets are still not correctly highlighted, and may never be since it requires pretty advanced recursive regex to be able to do it in Textmate

@jeff-hykin jeff-hykin changed the title Shell script syntax highlighting gets confused when using dictionary with square brackets in key name Nested square brackets for dictionaries cause problems Apr 16, 2024
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

No branches or pull requests

2 participants