jeff-hykin / better-shell-syntax

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

for loop highlighting inconsistent without `in` #68

Closed 1480c1 closed 7 months ago

1480c1 commented 1 year ago

The code with a problem is:

for a; do
    echo "$a"
done

It looks like:

screenshot + theme name preferable image Theme: Dark Modern

It should look like:

description of ideal the a should be high-lighted as the same blue when in "$@" is present image https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03 specifies the two should be equivalent.

1480c1 commented 1 year ago

I got it to highlight using

diff --git a/autogenerated/shell.tmLanguage.json b/autogenerated/shell.tmLanguage.json
index 345b50b..08b4bc4 100644
--- a/autogenerated/shell.tmLanguage.json
+++ b/autogenerated/shell.tmLanguage.json
@@ -1160,6 +1160,34 @@
             }
           ]
         },
+        {
+          "begin": "(?<=^|;|&|\\s)(for)\\s+(.+?)(?=\\s|;|&|$)",
+          "beginCaptures": {
+            "1": {
+              "name": "keyword.control.shell"
+            },
+            "2": {
+              "name": "variable.other.loop.shell",
+              "patterns": [
+                {
+                  "include": "#string"
+                }
+              ]
+            }
+          },
+          "end": "(?<=^|;|&|\\s)done(?=\\s|;|&|$|\\))",
+          "endCaptures": {
+            "0": {
+              "name": "keyword.control.shell"
+            }
+          },
+          "name": "meta.scope.for-in-loop.shell",
+          "patterns": [
+            {
+              "include": "#initial_context"
+            }
+          ]
+        },
         {
           "begin": "(?<=^|;|&|\\s)(while|until)(?=\\s|;|&|$)",
           "beginCaptures": {

image

jeff-hykin commented 7 months ago

should be fixed now! and thanks for the diff @1480c1 !