Fix workspace edit format for update md paths on move (#158965)

Unblocks testing #158416
This commit is contained in:
Matt Bierner 2022-08-23 16:33:00 -07:00 committed by GitHub
parent 6e7b7a33e6
commit 940abc9c11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@
import * as path from 'path';
import * as picomatch from 'picomatch';
import * as vscode from 'vscode';
import { BaseLanguageClient } from 'vscode-languageclient';
import { BaseLanguageClient, TextDocumentEdit } from 'vscode-languageclient';
import * as nls from 'vscode-nls';
import { getEditForFileRenames } from '../protocol';
import { Delayer } from '../util/async';
@ -206,13 +206,13 @@ class UpdateLinksOnFileRenameHandler extends Disposable {
token: vscode.CancellationToken,
): Promise<boolean> {
const edit = await this.client.sendRequest(getEditForFileRenames, [{ oldUri: oldUri.toString(), newUri: newUri.toString() }], token);
if (!edit.changes) {
if (!edit.documentChanges?.length) {
return false;
}
for (const [path, edits] of Object.entries(edit.changes)) {
const uri = vscode.Uri.parse(path);
for (const edit of edits) {
for (const change of edit.documentChanges as TextDocumentEdit[]) {
const uri = vscode.Uri.parse(change.textDocument.uri);
for (const edit of change.edits) {
workspaceEdit.replace(uri, convertRange(edit.range), edit.newText);
}
}