Skip to content

Commit

Permalink
Fix snippetTextEdits applying to other files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TimoFreiberg committed Jul 21, 2020
1 parent a3ff275 commit bfa1bbf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions editors/code/src/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bfa1bbf

Please sign in to comment.