fix: parse dot operation on atomic expression correctly (#497)

This commit is contained in:
Myriad-Dreamin 2024-08-05 19:47:55 +08:00 committed by GitHub
parent fb0a300bc2
commit 11f9965c48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 1 deletions

View file

@ -311,7 +311,8 @@ const enterExpression = (kind: string, seek: RegExp): textmate.Pattern => {
return {
/// name: 'markup.expr.typst'
begin: new RegExp("#" + seek.source),
end: /(?<=;)|(?<=[\)\]\}])(?![;\(\[\$])|(?=[\s\}\]\)\$]|$)|(;)/,
// `?=(?<![\d#])\.[^\p{XID_Start}_]`: This means that we are on a dot and the next character is not a valid identifier start, but we are not at the beginning of hash or number
end: /(?<=;)|(?<=[\)\]\}])(?![;\(\[\$])|(?=(?<![#\d])\.[^\p{XID_Start}_])|(?=[\s\}\]\)\$]|$)|(;)/u,
beginCaptures: {
"0": {
name: kind,

View file

@ -0,0 +1,2 @@
"#spec_char.d8." For example
"#spec_char.d8.a" For example

View file

@ -0,0 +1,20 @@
>"#spec_char.d8." For example
#^ source.typst
# ^ source.typst variable.other.readwrite.hash.typst
# ^^^^^^^^^ source.typst variable.other.readwrite.typst
# ^ source.typst keyword.operator.accessor.typst
# ^^ source.typst variable.other.readwrite.typst
# ^ source.typst keyword.operator.accessor.typst
# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst
# ^^^^^^^^^^^^^ source.typst string.quoted.double.typst
>"#spec_char.d8.a" For example
#^ source.typst string.quoted.double.typst punctuation.definition.string.typst
# ^ source.typst
# ^^^^^^^^^ source.typst variable.other.readwrite.typst
# ^ source.typst keyword.operator.accessor.typst
# ^^ source.typst variable.other.readwrite.typst
# ^ source.typst keyword.operator.accessor.typst
# ^ source.typst variable.other.readwrite.typst
# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst
# ^^^^^^^^^^^^^ source.typst string.quoted.double.typst
>