From 4923404e98db87bf99038bfa1e3d1dbf322194b4 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 12 May 2022 15:22:18 -0700 Subject: [PATCH] Don't include leading `@` in JS/TS completion word range (#149400) Fixes #149385 --- .../src/languageFeatures/completions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extensions/typescript-language-features/src/languageFeatures/completions.ts b/extensions/typescript-language-features/src/languageFeatures/completions.ts index 48149e56980..46a32ec68f6 100644 --- a/extensions/typescript-language-features/src/languageFeatures/completions.ts +++ b/extensions/typescript-language-features/src/languageFeatures/completions.ts @@ -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));