|
| 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 | +} |
0 commit comments