From 2ab82c12ed809fd1df921d016eed344a18a9ee8f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 11 Jan 2019 15:42:03 -0800 Subject: [PATCH] Make sure we opt in to new TS user preferences for enabling rename features Fixes #66176 --- .../src/features/fileConfigurationManager.ts | 6 ++++-- .../typescript-language-features/src/features/rename.ts | 9 +++++++-- .../typescript-language-features/src/languageProvider.ts | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/extensions/typescript-language-features/src/features/fileConfigurationManager.ts b/extensions/typescript-language-features/src/features/fileConfigurationManager.ts index d93bdce3367cc..794396595b25f 100644 --- a/extensions/typescript-language-features/src/features/fileConfigurationManager.ts +++ b/extensions/typescript-language-features/src/features/fileConfigurationManager.ts @@ -186,8 +186,10 @@ export default class FileConfigurationManager { return { quotePreference: getQuoteStylePreference(preferences), importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferences), - allowTextChangesInNewFiles: document.uri.scheme === 'file' - }; + allowTextChangesInNewFiles: document.uri.scheme === 'file', + providePrefixAndSuffixTextForRename: true, + allowRenameOfImportPath: true, + } as Proto.UserPreferences; } } diff --git a/extensions/typescript-language-features/src/features/rename.ts b/extensions/typescript-language-features/src/features/rename.ts index 7112cb9186731..ebcc30a8c68f8 100644 --- a/extensions/typescript-language-features/src/features/rename.ts +++ b/extensions/typescript-language-features/src/features/rename.ts @@ -10,12 +10,14 @@ import * as Proto from '../protocol'; import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService'; import API from '../utils/api'; import * as typeConverters from '../utils/typeConverters'; +import FileConfigurationManager from './fileConfigurationManager'; const localize = nls.loadMessageBundle(); class TypeScriptRenameProvider implements vscode.RenameProvider { public constructor( - private readonly client: ITypeScriptServiceClient + private readonly client: ITypeScriptServiceClient, + private readonly fileConfigurationManager: FileConfigurationManager ) { } public async prepareRename( @@ -90,6 +92,7 @@ class TypeScriptRenameProvider implements vscode.RenameProvider { }; return this.client.interuptGetErr(() => { + this.fileConfigurationManager.ensureConfigurationForDocument(document, token); return this.client.execute('rename', args, token); }); } @@ -143,6 +146,8 @@ class TypeScriptRenameProvider implements vscode.RenameProvider { export function register( selector: vscode.DocumentSelector, client: ITypeScriptServiceClient, + fileConfigurationManager: FileConfigurationManager, ) { - return vscode.languages.registerRenameProvider(selector, new TypeScriptRenameProvider(client)); + return vscode.languages.registerRenameProvider(selector, + new TypeScriptRenameProvider(client, fileConfigurationManager)); } diff --git a/extensions/typescript-language-features/src/languageProvider.ts b/extensions/typescript-language-features/src/languageProvider.ts index 51f3b91beafb2..dc25b87ee7347 100644 --- a/extensions/typescript-language-features/src/languageProvider.ts +++ b/extensions/typescript-language-features/src/languageProvider.ts @@ -71,7 +71,7 @@ export default class LanguageProvider extends Disposable { this._register((await import('./features/refactor')).register(selector, this.client, this.fileConfigurationManager, this.commandManager, this.telemetryReporter)); this._register((await import('./features/references')).register(selector, this.client)); this._register((await import('./features/referencesCodeLens')).register(selector, this.description.id, this.client, cachedResponse)); - this._register((await import('./features/rename')).register(selector, this.client)); + this._register((await import('./features/rename')).register(selector, this.client, this.fileConfigurationManager)); this._register((await import('./features/signatureHelp')).register(selector, this.client)); this._register((await import('./features/tagClosing')).register(selector, this.description.id, this.client)); this._register((await import('./features/typeDefinitions')).register(selector, this.client));