дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Add editor.textStart / editor.textEnd and their With Selection variants, mapped to EditorTextStart / EditorTextEnd / EditorTextStartWithSelection / EditorTextEndWithSelection for IdeaVim and imported keymaps. The plain moves leave a single caret at the document boundary; the With Selection variants extend each selection from its anchor. The actions stay unbound in the default keymaps like the other plain caret moves, so the editor's own Ctrl+Home/End (Cmd+Home/End, Cmd+Up/Down on macOS) keep handling the keys and Navigation Bar, Jump to Source and Move Statement keep their macOS shortcuts. Co-authored-by: muutot <[email protected]>
38 рядки
1.6 KiB
TypeScript
38 рядки
1.6 KiB
TypeScript
import { expect, openFromTree, test } from "./fixtures";
|
|
|
|
test("Move Caret to Text Start/End moves the caret and extends the selection", async ({ workbench: page }) => {
|
|
await openFromTree(page, "build.gradle.kts");
|
|
const editor = page.locator(".cm-editor").first();
|
|
await editor.locator(".cm-content").focus();
|
|
const state = async () =>
|
|
page.evaluate(async () => {
|
|
const path = "/src/editor/api.ts";
|
|
const { activeEditor } = await import(/* @vite-ignore */ path);
|
|
const view = (activeEditor() as { view?: { state: unknown } } | null)?.view;
|
|
if (!view) return null;
|
|
const s = (
|
|
view as never as { state: { doc: { length: number }; selection: { main: { head: number; anchor: number } } } }
|
|
).state;
|
|
return { docLength: s.doc.length, head: s.selection.main.head, anchor: s.selection.main.anchor };
|
|
});
|
|
const run = (id: string) =>
|
|
page.evaluate(async (action) => {
|
|
const path = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ path);
|
|
await executeAction(action);
|
|
}, id);
|
|
const before = await state();
|
|
expect(before).not.toBeNull();
|
|
|
|
await run("editor.textEnd");
|
|
expect((await state())!.head).toBe(before!.docLength);
|
|
await run("editor.textStart");
|
|
expect((await state())!.head).toBe(0);
|
|
await run("editor.textEndWithSelection");
|
|
const extended = (await state())!;
|
|
expect(extended.head).toBe(extended.docLength);
|
|
expect(extended.anchor).toBe(0);
|
|
await run("editor.textStartWithSelection");
|
|
expect(await state()).toMatchObject({ anchor: 0, head: 0 });
|
|
});
|