don't work too much unneccesarily...
This commit is contained in:
parent
e588a9cd1a
commit
802fdbac9f
|
@ -136,17 +136,19 @@ function getWordToLineNumbersMap(model: ITextModel | null): Map<string, number[]
|
||||||
model.forceTokenization(lineNumber);
|
model.forceTokenization(lineNumber);
|
||||||
const lineTokens = model.getLineTokens(lineNumber);
|
const lineTokens = model.getLineTokens(lineNumber);
|
||||||
for (let tokenIndex = 0, tokenCount = lineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
|
for (let tokenIndex = 0, tokenCount = lineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
|
||||||
const tokenStartOffset = lineTokens.getStartOffset(tokenIndex);
|
|
||||||
const tokenEndOffset = lineTokens.getEndOffset(tokenIndex);
|
|
||||||
const tokenType = lineTokens.getStandardTokenType(tokenIndex);
|
const tokenType = lineTokens.getStandardTokenType(tokenIndex);
|
||||||
const tokenStr = lineContent.substring(tokenStartOffset, tokenEndOffset);
|
|
||||||
|
|
||||||
// Token is a word and not a comment
|
// Token is a word and not a comment
|
||||||
if (tokenType === StandardTokenType.Other) {
|
if (tokenType === StandardTokenType.Other) {
|
||||||
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
|
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
|
||||||
|
|
||||||
|
const tokenStartOffset = lineTokens.getStartOffset(tokenIndex);
|
||||||
|
const tokenEndOffset = lineTokens.getEndOffset(tokenIndex);
|
||||||
|
const tokenStr = lineContent.substring(tokenStartOffset, tokenEndOffset);
|
||||||
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
|
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
|
||||||
|
|
||||||
if (wordMatch) {
|
if (wordMatch) {
|
||||||
|
|
||||||
const word = wordMatch[0];
|
const word = wordMatch[0];
|
||||||
if (!result.has(word)) {
|
if (!result.has(word)) {
|
||||||
result.set(word, []);
|
result.set(word, []);
|
||||||
|
|
Loading…
Reference in a new issue