mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Fix snippetTextEdits applying to other files
vscode.window.visibleTextEditors only contains editors whose contents are being displayed at the moment, so the previous logic only worked if the other file for which a snippetTextEdit is being received was visible in a separate split.
This commit is contained in:
parent
e72c6220cd
commit
1b5a74ef18
1 changed files with 4 additions and 0 deletions
|
@ -6,6 +6,10 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) {
|
|||
assert(edit.entries().length === 1, `bad ws edit: ${JSON.stringify(edit)}`);
|
||||
const [uri, edits] = edit.entries()[0];
|
||||
|
||||
if (vscode.window.activeTextEditor?.document.uri !== uri) {
|
||||
// `vscode.window.visibleTextEditors` only contains editors whose contents are being displayed
|
||||
await vscode.window.showTextDocument(uri, {});
|
||||
}
|
||||
const editor = vscode.window.visibleTextEditors.find((it) => it.document.uri.toString() === uri.toString());
|
||||
if (!editor) return;
|
||||
await applySnippetTextEdits(editor, edits);
|
||||
|
|
Loading…
Reference in a new issue