jeff-hykin / better-shell-syntax

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

Shell Script case...esac syntax highlight is broken #84

Open Sarisan opened 3 months ago

Sarisan commented 3 months ago

The code with a problem is:

#!/usr/bin/env dash

case "${1}" in
    (opt1)
        opt1=true

        if [ -n "${2}" ]
        then
            opt1arg="${2}"
            shift
        fi
    ;;
    (opt2)
        opt2=true

        case "${2}" in
            (s)
                echo "S"
            ;;
            (d)
                echo "D"
            ;;
            (*)
                echo "Missing"
            ;;
        esac

        if [ -n "${HOME}" ]
        then
            echo "${HOME}"
        fi
    ;;
    (opt3)
        opt3=true

        if [ -n "${2}" ]
        then
            opt3arg="${2}"
            shift
        fi

        echo "This is opt3"
    ;;
esac

It looks like:

GitHub Dark Default theme

Screenshot 2024-04-05 095729

It should look like:

Extension v1.6.3

Screenshot 2024-04-05 122443

alexr00 commented 3 months ago

Originally in https://github.com/microsoft/vscode/issues/209602.

levi-ee commented 2 months ago

I'll not open a new issue because this is certainly related:

case $test in
    foo)
        # a comment
        echo bar
        ;;
esac

case $test in
    foo) # a comment
        echo bar
        ;;
esac

2024-04-09 17_13_55-Window

The result is OK in the first case and not in the 2nd (lines 13 and 14). This happens every time we add a comment in the same line as the "pattern)".

Also, I think the "foo" should have the same color (string) as the "bar".

Theme: Dark Modern

Edit 2024-04-16: This is broken since 1.7.0

jeff-hykin commented 2 months ago

I've long held that C++ has the worst syntax known to man, but Bash sure do be trying to change my mind

jeff-hykin commented 2 months ago

should be fixed on v1.8.4

andyneff commented 2 months ago

The OP example is fixed in v1.8.6, but this example is still not parsing correctly.

I'll not open a new issue because this is certainly related:

case $test in
    foo)
        # a comment
        echo bar
        ;;
esac

case $test in
    foo) # a comment
        echo bar
        ;;
esac

2024-04-09 17_13_55-Window

The result is OK in the first case and not in the 2nd (lines 13 and 14). This happens every time we add a comment in the same line as the "pattern)".

Also, I think the "foo" should have the same color (string) as the "bar".

Theme: Dark Modern

Edit 2024-04-16: This is broken since 1.7.0

casperklein commented 1 month ago

The OP example is fixed in v1.8.6, but this example is still not parsing correctly.

I think have a the same or a related issue:

Broken syntax highlight (with comment) syntax-broken

Working syntax highlight (without comment) syntax-ok-with-comment-removed