[vb] fix string literals

aims to close microsoft/monaco-editor#1958 and microsoft/monaco-editor#1941
This commit is contained in:
skacurt 2020-05-09 01:51:10 +03:00
parent 618f2cff2d
commit 93f8458ba0
2 changed files with 86 additions and 9 deletions

View file

@ -289,18 +289,95 @@ testTokenization('vb', [
{ startIndex: 8, type: '' }, { startIndex: 8, type: '' },
{ startIndex: 9, type: 'delimiter.vb' }, { startIndex: 9, type: 'delimiter.vb' },
{ startIndex: 10, type: '' }, { startIndex: 10, type: '' },
{ startIndex: 11, type: 'string.vb' } { startIndex: 11, type: 'string.quote.vb' },
{ startIndex: 12, type: 'string.vb' },
{ startIndex: 18, type: 'string.quote.vb' }
] ]
}], }],
[{ [{
line: '"use strict";', line: '"use strict";',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.vb' }, { startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 11, type: 'string.quote.vb' },
{ startIndex: 12, type: 'delimiter.vb' } { startIndex: 12, type: 'delimiter.vb' }
] ]
}], }],
[{
line: '"a""b"',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 2, type: 'string.escape.vb' },
{ startIndex: 4, type: 'string.vb' },
{ startIndex: 5, type: 'string.quote.vb' }
]
}, {
line: '"a““b"',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 2, type: 'string.escape.vb' },
{ startIndex: 4, type: 'string.vb' },
{ startIndex: 5, type: 'string.quote.vb' }
]
}, {
line: '"a””b"',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 2, type: 'string.escape.vb' },
{ startIndex: 4, type: 'string.vb' },
{ startIndex: 5, type: 'string.quote.vb' }
]
}],
[{
line: '"mixed quotes 1“',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}, {
line: '"mixed quotes 2”',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}, {
line: '“mixed quotes 3"',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}, {
line: '“mixed quotes 4”',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}, {
line: '”mixed quotes 5"',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}, {
line: '”mixed quotes 6“',
tokens: [
{ startIndex: 0, type: 'string.quote.vb' },
{ startIndex: 1, type: 'string.vb' },
{ startIndex: 15, type: 'string.quote.vb' }
]
}],
// Tags // Tags
[{ [{
line: 'Public Sub ToString()', line: 'Public Sub ToString()',
@ -445,12 +522,14 @@ testTokenization('vb', [
{ startIndex: 5, type: '' }, { startIndex: 5, type: '' },
{ startIndex: 6, type: 'delimiter.vb' }, { startIndex: 6, type: 'delimiter.vb' },
{ startIndex: 7, type: '' }, { startIndex: 7, type: '' },
{ startIndex: 8, type: 'string.vb' } { startIndex: 8, type: 'string.quote.vb' },
{ startIndex: 9, type: 'string.vb' }
] ]
}, { }, {
line: 'world"', line: 'world"',
tokens: [ tokens: [
{ startIndex: 0, type: 'string.vb' }, { startIndex: 0, type: 'string.vb' },
{ startIndex: 5, type: 'string.quote.vb' }
] ]
}], }],

View file

@ -124,7 +124,6 @@ export const language = <ILanguage>{
// we include these common regular expressions // we include these common regular expressions
symbols: /[=><!~?;\.,:&|+\-*\/\^%]+/, symbols: /[=><!~?;\.,:&|+\-*\/\^%]+/,
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
integersuffix: /U?[DI%L&S@]?/, integersuffix: /U?[DI%L&S@]?/,
floatsuffix: /[R#F!]?/, floatsuffix: /[R#F!]?/,
@ -169,7 +168,7 @@ export const language = <ILanguage>{
[/@symbols/, 'delimiter'], [/@symbols/, 'delimiter'],
// strings // strings
[/"/, 'string', '@string'], [/["\u201c\u201d]/, { token: 'string.quote', next: '@string' }],
], ],
@ -179,10 +178,9 @@ export const language = <ILanguage>{
], ],
string: [ string: [
[/[^\\"]+/, 'string'], [/[^"\u201c\u201d]+/, 'string'],
[/@escapes/, 'string.escape'], [/["\u201c\u201d]{2}/, 'string.escape'],
[/\\./, 'string.escape.invalid'], [/["\u201c\u201d]C?/, { token: 'string.quote', next: '@pop' }]
[/"C?/, 'string', '@pop']
], ],
}, },
}; };