Skip to content

Commit

Permalink
Make sure we opt in to new TS user preferences for enabling rename fe…
Browse files Browse the repository at this point in the history
…atures

Fixes microsoft#66176
  • Loading branch information
mjbvz committed Jan 11, 2019
1 parent d3d16d2 commit 2ab82c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 2ab82c1

Please sign in to comment.