mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
parent
62d8f662fb
commit
c0799f0308
|
@ -61,7 +61,11 @@ export class UnicodeTextModelHighlighter {
|
|||
}
|
||||
}
|
||||
const str = lineContent.substring(startIndex, endIndex);
|
||||
const word = getWordAtText(startIndex + 1, DEFAULT_WORD_REGEXP, lineContent, 0);
|
||||
let word = getWordAtText(startIndex + 1, DEFAULT_WORD_REGEXP, lineContent, 0);
|
||||
if (word && word.endColumn <= startIndex + 1) {
|
||||
// The word does not include the problematic character, ignore the word
|
||||
word = null;
|
||||
}
|
||||
const highlightReason = codePointHighlighter.shouldHighlightNonBasicASCII(str, word ? word.word : null);
|
||||
|
||||
if (highlightReason !== SimpleHighlightReason.None) {
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import assert = require('assert');
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { UnicodeHighlighterOptions, UnicodeTextModelHighlighter } from 'vs/editor/common/services/unicodeTextModelHighlighter';
|
||||
import { createTextModel } from 'vs/editor/test/common/testTextModel';
|
||||
|
||||
suite('UnicodeTextModelHighlighter', () => {
|
||||
ensureNoDisposablesAreLeakedInTestSuite();
|
||||
|
||||
function t(text: string, options: UnicodeHighlighterOptions): unknown {
|
||||
const m = createTextModel(text);
|
||||
const r = UnicodeTextModelHighlighter.computeUnicodeHighlights(m, options);
|
||||
m.dispose();
|
||||
|
||||
return {
|
||||
...r,
|
||||
ranges: r.ranges.map(r => Range.lift(r).toString())
|
||||
};
|
||||
}
|
||||
|
||||
test('computeUnicodeHighlights (#168068)', () => {
|
||||
assert.deepStrictEqual(
|
||||
t(`
|
||||
For å gi et eksempel
|
||||
`, {
|
||||
allowedCodePoints: [],
|
||||
allowedLocales: [],
|
||||
ambiguousCharacters: true,
|
||||
invisibleCharacters: true,
|
||||
includeComments: false,
|
||||
includeStrings: false,
|
||||
nonBasicASCII: false
|
||||
}),
|
||||
{
|
||||
ambiguousCharacterCount: 0,
|
||||
hasMore: false,
|
||||
invisibleCharacterCount: 4,
|
||||
nonBasicAsciiCharacterCount: 0,
|
||||
ranges: [
|
||||
'[2,5 -> 2,6]',
|
||||
'[2,7 -> 2,8]',
|
||||
'[2,10 -> 2,11]',
|
||||
'[2,13 -> 2,14]'
|
||||
]
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue