This commit is contained in:
Anton Gogolev 2025-12-20 08:32:04 +01:00 committed by GitHub
commit 6b9686bd93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 2 deletions

View file

@ -216,6 +216,57 @@ testTokenization('python', [
] ]
} }
], ],
// https://github.com/microsoft/monaco-editor/issues/4601
[
{
line: `f'''str `,
tokens: [
{ startIndex: 0, type: 'string.escape.python' },
{ startIndex: 4, type: 'string.python' }
]
},
{
line: ` str "{var}" {{ {{ }} `,
tokens: [
{ startIndex: 0, type: 'string.python' },
{ startIndex: 6, type: 'identifier.python' },
{ startIndex: 11, type: 'string.python' }
]
},
{
line: `str'''`,
tokens: [
{ startIndex: 0, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' }
]
}
],
[
{
line: `f"""str `,
tokens: [
{ startIndex: 0, type: 'string.escape.python' },
{ startIndex: 4, type: 'string.python' }
]
},
{
line: ` str '{var}' {{ {{ }} `,
tokens: [
{ startIndex: 0, type: 'string.python' },
{ startIndex: 6, type: 'identifier.python' },
{ startIndex: 11, type: 'string.python' }
]
},
{
line: `str"""`,
tokens: [
{ startIndex: 0, type: 'string.python' },
{ startIndex: 3, type: 'string.escape.python' }
]
}
],
[ [
{ {
line: 'f"{var:.3f}{var!r}{var=}"', line: 'f"{var:.3f}{var!r}{var=}"',

View file

@ -257,7 +257,8 @@ export const language = <languages.IMonarchLanguage>{
[/"/, 'string.escape', '@dblStringBody'] [/"/, 'string.escape', '@dblStringBody']
], ],
fStringBody: [ fStringBody: [
[/[^\\'\{\}]+$/, 'string', '@popall'], [/\{\{/, 'string'],
[/\}\}/, 'string'],
[/[^\\'\{\}]+/, 'string'], [/[^\\'\{\}]+/, 'string'],
[/\{[^\}':!=]+/, 'identifier', '@fStringDetail'], [/\{[^\}':!=]+/, 'identifier', '@fStringDetail'],
[/\\./, 'string'], [/\\./, 'string'],
@ -272,7 +273,8 @@ export const language = <languages.IMonarchLanguage>{
[/\\$/, 'string'] [/\\$/, 'string']
], ],
fDblStringBody: [ fDblStringBody: [
[/[^\\"\{\}]+$/, 'string', '@popall'], [/\{\{/, 'string'],
[/\}\}/, 'string'],
[/[^\\"\{\}]+/, 'string'], [/[^\\"\{\}]+/, 'string'],
[/\{[^\}':!=]+/, 'identifier', '@fStringDetail'], [/\{[^\}':!=]+/, 'identifier', '@fStringDetail'],
[/\\./, 'string'], [/\\./, 'string'],