mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
chore: optimized code
This commit is contained in:
@@ -191,11 +191,12 @@ export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
||||
async doRename(document: TextDocument, position: Position, newName: string) {
|
||||
const jsDocument = jsDocuments.get(document);
|
||||
const jsLanguageService = await host.getLanguageService(jsDocument);
|
||||
const { canRename } = jsLanguageService.getRenameInfo(jsDocument.uri, jsDocument.offsetAt(position));
|
||||
const jsDocumentPosition = jsDocument.offsetAt(position);
|
||||
const { canRename } = jsLanguageService.getRenameInfo(jsDocument.uri, jsDocumentPosition);
|
||||
if (!canRename) {
|
||||
return null;
|
||||
}
|
||||
const renameInfos = jsLanguageService.findRenameLocations(jsDocument.uri, jsDocument.offsetAt(position), false, false);
|
||||
const renameInfos = jsLanguageService.findRenameLocations(jsDocument.uri, jsDocumentPosition, false, false);
|
||||
|
||||
const edits: TextEdit[] = [];
|
||||
renameInfos?.map(renameInfo => {
|
||||
|
||||
@@ -28,10 +28,6 @@ async function testRename(value: string, newName: string, expectedDocContent: st
|
||||
assert.fail('No workspace edits');
|
||||
}
|
||||
|
||||
if (!workspaceEdit || !workspaceEdit.changes) {
|
||||
assert.fail('No workspace edits');
|
||||
}
|
||||
|
||||
const edits = workspaceEdit.changes[document.uri.toString()];
|
||||
if (!edits) {
|
||||
assert.fail(`No edits for file at ${document.uri.toString()}`);
|
||||
|
||||
Reference in New Issue
Block a user