mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
feat: add rename symbol within <script> tags
This commit is contained in:
parent
f89bb0d54a
commit
94b2772f8c
|
@ -501,9 +501,10 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
|
|||
const position: Position = params.position;
|
||||
|
||||
if (document) {
|
||||
const htmlMode = languageModes.getMode('html');
|
||||
if (htmlMode && htmlMode.doRename) {
|
||||
return htmlMode.doRename(document, position, params.newName);
|
||||
const mode = languageModes.getModeAtPosition(document, params.position);
|
||||
|
||||
if (mode && mode.doRename) {
|
||||
return mode.doRename(document, position, params.newName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -188,6 +188,23 @@ export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
|||
}
|
||||
return null;
|
||||
},
|
||||
async doRename(document: TextDocument, position: Position, newName: string) {
|
||||
const jsDocument = jsDocuments.get(document);
|
||||
const jsLanguageService = await host.getLanguageService(jsDocument);
|
||||
const renameInfos = jsLanguageService.findRenameLocations(jsDocument.uri, jsDocument.offsetAt(position), false, false);
|
||||
|
||||
const edits: TextEdit[] = [];
|
||||
renameInfos?.map(renameInfo => {
|
||||
edits.push({
|
||||
range: convertRange(jsDocument, renameInfo.textSpan),
|
||||
newText: newName,
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
changes: { [document.uri]: edits },
|
||||
};
|
||||
},
|
||||
async findDocumentHighlight(document: TextDocument, position: Position): Promise<DocumentHighlight[]> {
|
||||
const jsDocument = jsDocuments.get(document);
|
||||
const jsLanguageService = await host.getLanguageService(jsDocument);
|
||||
|
|
Loading…
Reference in a new issue