jeff-hykin / better-shell-syntax

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

Inconsistent syntax highlighting for shell case statements #80

Closed alexr00 closed 8 months ago

alexr00 commented 8 months ago

The code with a problem is:

#!/bin/sh
case "$1" in
case1)
cmd1 cmd1_arg1 cmd1_arg2 cmd1_arg3;;
case2) cmd2 cmd2_arg1 cmd2_arg2 cmd2_arg3;;
esac

In a shell script case statement: 1) when the case pattern and command are placed on separate lines, the highlighter correctly recognizes the commands/arguments and colors them appropriately; they get placed into appropriate scopes.

2) When the case pattern and command are placed on the same line, the command and arguments are not recognized as such and are simply placed in a scope for a case clause body, which has no special highlighting.

On line 4:

On line 5:

#!/bin/sh
#shellcheck disable=SC2034
case "$1" in
    i) id="$OPTARG";;
    *)
esac

case "$1" in
    i)
        id="$OPTARG";;
    *)
esac

Same thing happens for keyword highlighting.

On line 4: " id" is placed into the meta.scope.case-clause-body.shell texmate scope, which has no foreground color set (so it displays with the default ('#D4D4D4')

On line 10, "id" is placed into the variable.other.assignment.shell scope and is highlighted as a variable (for me set to '#9CDCFE')

It looks like:

image

image

It should look like:

description of ideal

Originally from @slycordinator in https://github.com/microsoft/vscode/issues/207666

jeff-hykin commented 8 months ago

should be fixed in 1.7.0