VsCode Extension: Rename Symbols

匿名 (未验证) 提交于 2019-12-03 01:36:02

问题:

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.

回答1:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!