|
1 | | -hello; |
| 1 | +import { |
| 2 | + getCursorlessApi, |
| 3 | + openNewNotebookEditor, |
| 4 | +} from "@cursorless/vscode-common"; |
| 5 | +import assert from "assert"; |
| 6 | +import { window } from "vscode"; |
| 7 | +import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup"; |
| 8 | +import { runCursorlessCommand } from "@cursorless/vscode-common"; |
| 9 | + |
| 10 | +// Check that setSelection is able to focus the correct cell |
| 11 | +suite("Within cell set selection", async function () { |
| 12 | + endToEndTestSetup(this); |
| 13 | + |
| 14 | + test("Within cell set selection", runTest); |
| 15 | +}); |
| 16 | + |
| 17 | +async function runTest() { |
| 18 | + const { hatTokenMap } = (await getCursorlessApi()).testHelpers!; |
| 19 | + |
| 20 | + await openNewNotebookEditor(['"hello world"']); |
| 21 | + |
| 22 | + // FIXME: There seems to be some timing issue when you create a notebook |
| 23 | + // editor |
| 24 | + await sleepWithBackoff(1000); |
| 25 | + |
| 26 | + await hatTokenMap.allocateHats(); |
| 27 | + |
| 28 | + await runCursorlessCommand({ |
| 29 | + version: 1, |
| 30 | + action: "setSelection", |
| 31 | + targets: [ |
| 32 | + { |
| 33 | + type: "primitive", |
| 34 | + mark: { |
| 35 | + type: "decoratedSymbol", |
| 36 | + symbolColor: "default", |
| 37 | + character: "r", |
| 38 | + }, |
| 39 | + }, |
| 40 | + ], |
| 41 | + }); |
| 42 | + |
| 43 | + const editor = window.activeTextEditor; // eslint-disable-line no-restricted-properties |
| 44 | + |
| 45 | + if (editor == null) { |
| 46 | + assert(false, "No editor was focused"); |
| 47 | + } |
| 48 | + |
| 49 | + assert.deepStrictEqual(editor.document.getText(editor.selection), "world"); |
| 50 | +} |
0 commit comments