Packages: [Bash] Comment after redirection make next line wrong scope

Created on 23 Jun 2020  路  3Comments  路  Source: sublimehq/Packages

foo > ${bar} # comment
if [ $? -eq 0 ]; then
    # comment
fi

image
See the if and the condition.

References

All 3 comments

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index e973e319..106bb8a8 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -540,16 +540,17 @@ contexts:
   redirection-post:
     - match: \s*(?:(\d+)|(-))
       captures:
         1: constant.numeric.integer.decimal.file-descriptor.shell
         2: punctuation.terminator.file-descriptor.shell
       pop: true
     - match: \s*(?=\S)
       set:
+        - meta_include_prototype: false
         - match: (?={{metachar}}|`)
           pop: true
         - include: expansion-and-string
     - match: \s*
       pop: true

As mentioned in https://forum.sublimetext.com/t/color-bug-in-shell/51820/9, the above diff fixes this particular case (i.e., comment after redirection). @deathaxe seems to work on a better solution (as mentioned in https://forum.sublimetext.com/t/color-bug-in-shell/51820/10).

Should be fixed by https://github.com/deathaxe/sublime-packages/tree/pr/shellscript/patchset-2020

I'll open a pull request once the other PRs are merged and it becomes clear which of the open syntax related core issues are fixed as some of the changes in that branch may interfere with possible core changes.

The whole handling of comments is not optimal for several reasons. Fixing those issues required a couple of design changes. So the patchset-2020 will become a somewhat bigger PR. It should fix all of the known issues.

Was this page helpful?
0 / 5 - 0 ratings