Skip to content

Commit 7ddceac

Browse files
authored
Fix cross-split wrap with snippet (#1271)
1 parent 383eb4c commit 7ddceac

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { HatStability } from "@cursorless/common";
2+
import { getCursorlessApi, openNewEditor } from "@cursorless/vscode-common";
3+
import * as assert from "assert";
4+
import { endToEndTestSetup } from "../endToEndTestSetup";
5+
import { runCursorlessCommand } from "../runCommand";
6+
import { setupFake } from "./setupFake";
7+
8+
suite("Wrap with snippet across split", async function () {
9+
endToEndTestSetup(this);
10+
11+
suiteSetup(async () => {
12+
const { ide } = (await getCursorlessApi()).testHelpers!;
13+
setupFake(ide, HatStability.stable);
14+
});
15+
16+
test("Wrap with snippet across split", runTest);
17+
});
18+
19+
async function runTest() {
20+
const { graph } = (await getCursorlessApi()).testHelpers!;
21+
22+
const { document: document1 } = await openNewEditor("hello world");
23+
const { document: document2 } = await openNewEditor("", { openBeside: true });
24+
25+
await graph.hatTokenMap.allocateHats();
26+
27+
await runCursorlessCommand({
28+
version: 4,
29+
action: { name: "wrapWithSnippet", args: ["spaghetti.foo"] },
30+
targets: [
31+
{
32+
type: "primitive",
33+
mark: {
34+
type: "decoratedSymbol",
35+
symbolColor: "default",
36+
character: "h",
37+
},
38+
},
39+
],
40+
usePrePhraseSnapshot: false,
41+
});
42+
43+
assert.deepStrictEqual(
44+
document1.getText(),
45+
"My friend hello likes to eat spaghetti! world",
46+
);
47+
assert.deepStrictEqual(document2.getText(), "");
48+
}

src/ide/vscode/VscodeInsertSnippets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export async function vscodeInsertSnippet(
1111
editor.selections = ranges.map((range) => range.toSelection(false));
1212
}
1313

14+
await editor.focus();
1415
await vscode.commands.executeCommand("editor.action.insertSnippet", {
1516
snippet,
1617
});

0 commit comments

Comments
 (0)