jeff-hykin / better-shell-syntax

💾 📦 ♻️ An improvement to the shell syntax for VS Code
MIT License
51 stars 4 forks source link

Nested square brackets for dictionaries cause problems #74

Open alexr00 opened 8 months ago

alexr00 commented 8 months ago

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 https://github.com/microsoft/vscode/issues/202566

jeff-hykin commented 5 months ago

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 commented 5 months ago

(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