diff --git a/syntaxes/textmate/main.ts b/syntaxes/textmate/main.ts index bf1cc81f..87e7af69 100644 --- a/syntaxes/textmate/main.ts +++ b/syntaxes/textmate/main.ts @@ -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, diff --git a/syntaxes/textmate/tests/unit/bugs/expression-field.typ b/syntaxes/textmate/tests/unit/bugs/expression-field.typ new file mode 100644 index 00000000..a1ac6c6b --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/expression-field.typ @@ -0,0 +1,5 @@ +#link("https://microsoft.github.io/language-server-protocol/")[Language Server Protocol]. tinymist + +#{ + text(red)[] . fields() +} diff --git a/syntaxes/textmate/tests/unit/bugs/expression-field.typ.snap b/syntaxes/textmate/tests/unit/bugs/expression-field.typ.snap new file mode 100644 index 00000000..e00d15a5 --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/expression-field.typ.snap @@ -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 +> \ No newline at end of file