fix: properly stops call expressions (#273)

This commit is contained in:
Myriad-Dreamin 2024-05-12 00:32:53 +08:00 committed by GitHub
parent fff227f3ae
commit 6a438e79c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 1 deletions

View file

@ -1473,7 +1473,9 @@ const funcCallOrPropAccess = (strict: boolean): textmate.Pattern => {
/(\.\s*)?/.source + IDENTIFIER.source + /\s*(?=\(|\[)/.source
)
),
end: /(?:(?<=\)|\])(?:(?![\[\(\.])|$))|(?=[\n;\}\]\)]|$)/,
end: strict
? /(?:(?<=\)|\])(?:(?![\[\(\.])|$))|(?=[\s;\,\}\]\)]|$)/
: /(?:(?<=\)|\])(?:(?![\[\(\.])|$))|(?=[\n;\,\}\]\)]|$)/,
patterns: [
// todo: comments?
// {
@ -1627,6 +1629,7 @@ export const typst: textmate.Grammar = {
...setStatement().repository,
...showStatement().repository,
strictFuncCallOrPropAccess: funcCallOrPropAccess(true),
// todo: distinguish strict and non-strict for markup and code mode.
// funcCallOrPropAccess: funcCallOrPropAccess(false),
callArgs,
funcRestParam,

View file

@ -0,0 +1,5 @@
#link("https://microsoft.github.io/language-server-protocol/")[Language Server Protocol]. tinymist
#{
text(red)[] . fields()
}

View file

@ -0,0 +1,34 @@
>#link("https://microsoft.github.io/language-server-protocol/")[Language Server Protocol]. tinymist
#^ source.typst entity.name.function.hash.typst
# ^^^^ source.typst meta.expr.call.typst entity.name.function.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
# ^ source.typst meta.expr.call.typst string.quoted.double.typst punctuation.definition.string.typst
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst meta.expr.call.typst string.quoted.double.typst
# ^ source.typst meta.expr.call.typst string.quoted.double.typst punctuation.definition.string.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^^^^^^^^^^^^^^^^^^^^^^^^ source.typst meta.expr.call.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^ source.typst meta.expr.call.typst keyword.operator.accessor.typst
# ^^^^^^^^^^ source.typst
>
>#{
#^ source.typst keyword.control.hash.typst
# ^ source.typst meta.brace.curly.typst
> text(red)[] . fields()
#^^ source.typst
# ^^^^ source.typst meta.expr.call.typst entity.name.function.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
# ^^^ source.typst meta.expr.call.typst support.type.builtin.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^ source.typst meta.expr.call.typst meta.brace.square.typst
# ^^ source.typst
# ^ source.typst keyword.operator.accessor.typst
# ^^ source.typst
# ^^^^^^ source.typst meta.expr.call.typst entity.name.function.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
# ^ source.typst meta.expr.call.typst meta.brace.round.typst
>}
#^ source.typst meta.brace.curly.typst
>