Skip to content

Commit

Permalink
[Go] fix backtick strings inside function calls (#3868)
Browse files Browse the repository at this point in the history
* [Go] fix match-case-value context never popping off the stack

* [Go] fix backtick strings with embedded languages inside function calls
  • Loading branch information
keith-hall authored Nov 27, 2023
1 parent 37df50e commit cb1b534
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
21 changes: 3 additions & 18 deletions Go/Embeddings/Go (Embedded Backtick String).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contexts:
- match: '{{newline}}'
scope: comment.line.double-slash.go
set:
- match-any
- match-any-root
- consume-comments-at-beginning-of-line

consume-comments-at-beginning-of-line:
Expand All @@ -26,21 +26,6 @@ contexts:
- match: ^(?!\s*/[/*])
pop: true

match-any:
- meta_prepend: true
match-any-root:
- include: pop-on-eol

match-parens:
- meta_prepend: true
- match: (?=\))
pop: true

match-brackets:
- meta_prepend: true
- match: (?=\])
pop: true

match-braces:
- meta_prepend: true
- match: (?=\})
pop: true
- include: match-any
2 changes: 2 additions & 0 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,8 @@ contexts:
pop: true
- match: '{{predeclared_type}}'
scope: support.type.go
- match: (?=;)
pop: 1
- include: match-any

match-keyword-chan:
Expand Down
17 changes: 17 additions & 0 deletions Go/tests/syntax_test_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -5644,6 +5644,13 @@ func main() {
// plan9, windows...
fmt.Printf("%s.\n", os)
}
switch os {
case no_colon_here_while_user_is_typing
; a := b
// ^ punctuation.terminator
// ^ - punctuation.separator.case-statement
// ^^ keyword.operator.assignment
}
}
func do(i interface{}) {
Expand Down Expand Up @@ -5847,3 +5854,13 @@ func lang_embedding() {
// ^^^^^^^^^^^ meta.interpolation.go
// ^ meta.string.go string.quoted.backtick.go punctuation.definition.string.end.go
}
// language=sql
some_func_call(
args_on_next_line, `
SELECT min(a)
FROM b
WHERE c = @p1`, "some value",
// ^^^^^^^^^^^^^^ meta.string.go meta.embedded.go source.sql.embedded.go
)
// <- punctuation.section.parens.end.go - invalid

0 comments on commit cb1b534

Please sign in to comment.