Skip to content

Commit

Permalink
Merge #5480
Browse files Browse the repository at this point in the history
5480: Fix snippetTextEdits applying to other files r=matklad a=TimoFreiberg

Fixes #4551
`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.

I feel that this is a hacky approach, so feel free to reject it for something nicer :)

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
  • Loading branch information
bors[bot] and TimoFreiberg authored Jul 23, 2020
2 parents 803f361 + 1b5a74e commit 85532e2
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 85532e2

Please sign in to comment.