diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-23 13:33:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-23 13:33:24 +0100 |
commit | 85532e2df3f713f0fb9096328e86ec7e74934c12 (patch) | |
tree | 243b2e6000eca4941ae9c1a869730ac31cd4591c /editors/code | |
parent | 803f3613ba041a24b50c7e8249e9ee3195836ea8 (diff) | |
parent | 1b5a74ef18389f7d1a90cb6945a17bc412f707b4 (diff) |
Merge #5480
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 <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/snippets.ts | 4 |
1 files changed, 4 insertions, 0 deletions
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) { | |||
6 | assert(edit.entries().length === 1, `bad ws edit: ${JSON.stringify(edit)}`); | 6 | assert(edit.entries().length === 1, `bad ws edit: ${JSON.stringify(edit)}`); |
7 | const [uri, edits] = edit.entries()[0]; | 7 | const [uri, edits] = edit.entries()[0]; |
8 | 8 | ||
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 | } | ||
9 | const editor = vscode.window.visibleTextEditors.find((it) => it.document.uri.toString() === uri.toString()); | 13 | const editor = vscode.window.visibleTextEditors.find((it) => it.document.uri.toString() === uri.toString()); |
10 | if (!editor) return; | 14 | if (!editor) return; |
11 | await applySnippetTextEdits(editor, edits); | 15 | await applySnippetTextEdits(editor, edits); |