Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit df3035b

Browse files
committed
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. Ported from rust-analyzer: rust-lang/rust-analyzer#5480
1 parent 16f789c commit df3035b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rust-analyzer/editors/code/src/snippets.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export async function applySnippetWorkspaceEdit(edit: vscode.WorkspaceEdit) {
66
assert(edit.entries().length === 1, `bad ws edit: ${JSON.stringify(edit)}`);
77
const [uri, edits] = edit.entries()[0];
88

9+
if (vscode.window.activeTextEditor?.document.uri !== uri) {
10+
// `vscode.window.visibleTextEditors` only contains editors whose contents are being displayed
11+
await vscode.window.showTextDocument(uri, {});
12+
}
913
const editor = vscode.window.visibleTextEditors.find((it) => it.document.uri.toString() === uri.toString());
1014
if (!editor) return;
1115
await applySnippetTextEdits(editor, edits);

0 commit comments

Comments
 (0)