Skip to content

Commit

Permalink
Syntax: Improve shell line continuation
Browse files Browse the repository at this point in the history
Try to continue commands' contexts after line continuation operators
  • Loading branch information
deathaxe committed Jul 25, 2024
1 parent e1f5d4e commit 2c7a05f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion syntaxes/Shell (for Markdown).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ contexts:
- match: ^\s*(>)\s
captures:
1: comment.other.shell
scope: comment.other.shell

main:
- match: ^(?=\s*\$\s)
Expand All @@ -27,3 +26,12 @@ contexts:
1: comment.other.shell
embed: statements
escape: (?<![^\\]\\)(?<![\\]{3})\n

line-continuation-body:
- meta_prepend: true
- meta_include_prototype: false
# continuation lines begin with `> `
- match: ^\s*(>)\s
captures:
1: comment.other.shell
pop: 1
4 changes: 2 additions & 2 deletions tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ foo
# test
| ^^^^^ source.shell comment.line.number-sign
echo hello, \
| ^^ punctuation.separator.continuation.line
| ^ punctuation.separator.continuation.line
echo This is a smiley :-\) \(I have to escape the parentheses, though!\)
| ^^ constant.character.escape
```
Expand Down Expand Up @@ -2045,7 +2045,7 @@ unclosed_paren = (
function foo () {
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell keyword.declaration.function.shell
}
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell meta.compound.shell punctuation.section.compound.end.shell
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell punctuation.section

$ ls ~
| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive comment.other.shell
Expand Down

0 comments on commit 2c7a05f

Please sign in to comment.