Don't include leading `@` in JS/TS completion word range (#149400)

Fixes #149385
pull/149404/merge
Matt Bierner 2022-05-12 15:22:18 -07:00 committed by GitHub
parent 9b7577420d
commit 4923404e98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,6 @@ import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { Command, CommandManager } from '../commands/commandManager';
import type * as Proto from '../protocol';
import protocol = require('../protocol');
import * as PConst from '../protocol.const';
import { ClientCapability, ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
import API from '../utils/api';
@ -717,7 +716,14 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
return undefined;
}
const wordRange = document.getWordRangeAtPosition(position);
let wordRange = document.getWordRangeAtPosition(position);
if (wordRange && !wordRange.isEmpty) {
const secondCharPosition = wordRange.start.translate(0, 1);
const firstChar = document.getText(new vscode.Range(wordRange.start, secondCharPosition));
if (firstChar === '@') {
wordRange = wordRange.with(secondCharPosition);
}
}
await this.client.interruptGetErr(() => this.fileConfigurationManager.ensureConfigurationForDocument(document, token));