jeff-hykin / better-shell-syntax

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

for loop highlighting inconsistent without `in` #68

Closed 1480c1 closed 5 months ago

1480c1 commented 11 months 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 11 months 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 5 months ago

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