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

Shell script syntax highlighting gets confused when using dict with square brackets in key name #202566

Closed
SkyLined opened this issue Jan 16, 2024 · 2 comments
Assignees
Labels
grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream

Comments

@SkyLined
Copy link

Type: Bug

Create a new file in VSCode and add the following content:

#!/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)

On line 4, the syntax highlighter appears to understand that the code is setting a value of the a dict key named "[]" to x.
On line 5, the syntax highlighter gets confused: the code is getting a value of the a dict key named "[]", but instead of rendering the entire key name as a value, it appears to believe the key name ends at the closing square bracket in the key name (i.e. key name is "[). This also means that the closing double quote in the key name is considered to be an opening quote for a string, causing the remainder of the line (and subsequent lines) to be incorrectly shown as part of that string.

I've left out system information and extensions because they should be irrelevant.

VS Code version: Code 1.85.1 (0ee08df, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.22000
Modes:

A/B Experiments
vsliv368:30146709
vsreu685:30147344
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vshan820:30294714
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
py29gd2263:30899288
vsclangdc:30486549
c4g48928:30535728
azure-dev_surveyone:30548225
f6dab269:30613381
962ge761:30917236
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2cf:30928864
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30885898
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
aa_t_chat:30882232
cp7184t3:30927821

@RedCMD
Copy link
Contributor

RedCMD commented Jan 16, 2024

should move to the orignal repo https://github.com/jeff-hykin/better-shell-syntax

@alexr00
Copy link
Member

alexr00 commented Jan 17, 2024

Copied to jeff-hykin/better-shell-syntax#74

@alexr00 alexr00 closed this as completed Jan 17, 2024
@alexr00 alexr00 added grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream labels Jan 17, 2024
@SkyLined SkyLined changed the title Shell script syntax highlighting gets confused when using dict with squer brackets in key name Shell script syntax highlighting gets confused when using dict with square brackets in key name Jan 18, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

4 participants