Reputation: 162
Is there any why to trigger Rename Variable from a Extension?
I found an example how to rename a certain word in a file, but the reference variables keep the same as before.
Upvotes: 1
Views: 1516
Reputation: 65253
Try using the vscode.executeDocumentRenameProvider
command:
import * as vscode from 'vscode'
vscode.commands.executeCommand('vscode.executeDocumentRenameProvider',
vscode.window.activeTextEditor.document.uri,
new vscode.Position(targetLine, targetCharacter),
'newSymbolName').then(edit => {
if (!edit) {
return false;
}
return vscode.workspace.applyEdit(edit);
})
This will utilize the RenameProvider
that is registered for the target file. If no such RenameProvider
exists, you will need to implement one
Upvotes: 4