mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Merge pull request #2871 from juan-carlos-diaz/main
Fix #2851 Highlight correctly the attributes and identifiers (with dashes) for Shell language
This commit is contained in:
commit
9f0a9c263f
2 changed files with 43 additions and 3 deletions
|
|
@ -33,6 +33,40 @@ testTokenization('shell', [
|
||||||
{ startIndex: 14, type: 'white.shell' },
|
{ startIndex: 14, type: 'white.shell' },
|
||||||
{ startIndex: 15, type: '' }
|
{ startIndex: 15, type: '' }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
// Tests for case reported in bug #2851, do not confuse identifier(with dashes) with attribute
|
||||||
|
{
|
||||||
|
line: 'foo-bar --baz gorp -123 --abc-123',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 7, type: 'white.shell' },
|
||||||
|
{ startIndex: 8, type: 'attribute.name.shell' },
|
||||||
|
{ startIndex: 13, type: 'white.shell' },
|
||||||
|
{ startIndex: 14, type: '' },
|
||||||
|
{ startIndex: 18, type: 'white.shell' },
|
||||||
|
{ startIndex: 19, type: 'attribute.name.shell' },
|
||||||
|
{ startIndex: 23, type: 'white.shell' },
|
||||||
|
{ startIndex: 24, type: 'attribute.name.shell' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// Bug #2851 add new definition 'Identifiers with dashes', here one test
|
||||||
|
{
|
||||||
|
line: 'foo | foo-bar | foo-bar-1 | foo-bar-2021-1',
|
||||||
|
tokens: [
|
||||||
|
{ startIndex: 0, type: '' },
|
||||||
|
{ startIndex: 3, type: 'white.shell' },
|
||||||
|
{ startIndex: 4, type: 'delimiter.shell' },
|
||||||
|
{ startIndex: 5, type: 'white.shell' },
|
||||||
|
{ startIndex: 6, type: '' },
|
||||||
|
{ startIndex: 13, type: 'white.shell' },
|
||||||
|
{ startIndex: 14, type: 'delimiter.shell' },
|
||||||
|
{ startIndex: 15, type: 'white.shell' },
|
||||||
|
{ startIndex: 16, type: '' },
|
||||||
|
{ startIndex: 25, type: 'white.shell' },
|
||||||
|
{ startIndex: 26, type: 'delimiter.shell' },
|
||||||
|
{ startIndex: 27, type: 'white.shell' },
|
||||||
|
{ startIndex: 28, type: '' }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,13 +134,19 @@ export const language = <languages.IMonarchLanguage>{
|
||||||
'zsh'
|
'zsh'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
startingWithDash: /\-+\w+/,
|
||||||
|
|
||||||
|
identifiersWithDashes: /[a-zA-Z]\w+(?:@startingWithDash)+/,
|
||||||
|
|
||||||
// we include these common regular expressions
|
// we include these common regular expressions
|
||||||
symbols: /[=><!~?&|+\-*\/\^;\.,]+/,
|
symbols: /[=><!~?&|+\-*\/\^;\.,]+/,
|
||||||
|
|
||||||
// The main tokenizer for our languages
|
// The main tokenizer for our languages
|
||||||
tokenizer: {
|
tokenizer: {
|
||||||
root: [
|
root: [
|
||||||
{ include: '@whitespace' },
|
[/@identifiersWithDashes/, ''],
|
||||||
|
|
||||||
|
[/(\s)((?:@startingWithDash)+)/, ['white', 'attribute.name']],
|
||||||
|
|
||||||
[
|
[
|
||||||
/[a-zA-Z]\w*/,
|
/[a-zA-Z]\w*/,
|
||||||
|
|
@ -153,14 +159,14 @@ export const language = <languages.IMonarchLanguage>{
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
{ include: '@whitespace' },
|
||||||
|
|
||||||
{ include: '@strings' },
|
{ include: '@strings' },
|
||||||
{ include: '@parameters' },
|
{ include: '@parameters' },
|
||||||
{ include: '@heredoc' },
|
{ include: '@heredoc' },
|
||||||
|
|
||||||
[/[{}\[\]()]/, '@brackets'],
|
[/[{}\[\]()]/, '@brackets'],
|
||||||
|
|
||||||
[/-+\w+/, 'attribute.name'],
|
|
||||||
|
|
||||||
[/@symbols/, 'delimiter'],
|
[/@symbols/, 'delimiter'],
|
||||||
|
|
||||||
{ include: '@numbers' },
|
{ include: '@numbers' },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue