jeff-hykin / better-shell-syntax

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

Quoted array expansion inside loop breaks highlighting #34

Closed misaki-web closed 5 months ago

misaki-web commented 1 year ago

The code with a problem is:

#!/bin/bash

command_args=("/usr/bin/test-program" "arg1" "arg2")
posts=(1 3 4 10)

echo "Start"

for post in "${posts[@]}"; do
    "${command_args[@]}" "$post"
done

echo "End"

It looks like this (theme "Default Light+"):

screenshot-bash-highlighting-bug

It should look like:

If the array command_args is not quoted, or if it's not inside a loop, syntax highlighting is OK:

screenshot-bash-highlighting-bug-2

screenshot-bash-highlighting-bug-3

jeff-hykin commented 1 year ago

For reference, here's what it looks like on my end on v0.3.4

lime green = executable name

Screen Shot 2023-02-06 at 7 48 39 AM

So right now the last one ${command_args[@]} "$post" isn't matched correctly.

But what you're saying sounds a little different so I want to check with you to make sure I'm understanding the issue

misaki-web commented 1 year ago

Here's how your example is highlighted on my end when the line inside the loop is indented with a tab:

bash-syntax-highlighting-example

and when it's indented with spaces:

bash-syntax-highlighting-example-3

Also, here's how the original example is highlighted when the line inside the loop is indented with spaces instead of tab:

bash-syntax-highlighting-example-2

jeff-hykin commented 5 months ago

Not sure when it got fixed, but seems to be fixed now v1.8.5