From 1b5a74ef18389f7d1a90cb6945a17bc412f707b4 Mon Sep 17 00:00:00 2001 From: Timo Freiberg Date: Tue, 21 Jul 2020 19:47:27 +0200 Subject: 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. --- editors/code/src/snippets.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'editors/code') diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index bcb3f2cc7..258b49982 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -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); -- cgit v1.2.3