дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
With Vim on Windows and Linux, Ctrl+N and Ctrl+P in Insert mode went to the IDE keymap (Go to Class, Parameter Info) even while a completion list was open. While a list is open in Insert mode they now move its selection, unless the user set a handler for the stroke; Normal and Visual modes are unchanged. Fixes #7418
70 рядки
2.7 KiB
TypeScript
70 рядки
2.7 KiB
TypeScript
/** Vim's Insert-mode Ctrl+N / Ctrl+P move through an open completion lookup. */
|
|
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.addInitScript(() =>
|
|
localStorage.setItem("openidea.vim.v1", JSON.stringify({ enabled: true, handlers: {} })),
|
|
);
|
|
await page.goto("/");
|
|
await expect(page.getByRole("tree", { name: "Project" })).toBeVisible();
|
|
});
|
|
|
|
for (const preset of ["intellij-macos", "intellij-windows"]) {
|
|
test(`Ctrl+N / Ctrl+P move the lookup selection in Insert mode (${preset})`, async ({ page }) => {
|
|
const editor = await openFromTree(page, "build.gradle.kts");
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (preset) => {
|
|
const keymapModule = "/src/platform/keymap.ts";
|
|
const { applyKeymapSettings } = await import(keymapModule);
|
|
applyKeymapSettings(preset, {});
|
|
}, preset);
|
|
await expect(editor).toHaveAttribute("data-openidea-vim", "true");
|
|
await page.evaluate(() => {
|
|
const item = (label: string) => ({
|
|
label,
|
|
kind: "property",
|
|
detail: null,
|
|
labelDetail: null,
|
|
labelDescription: null,
|
|
documentation: null,
|
|
sortText: null,
|
|
filterText: null,
|
|
preselect: false,
|
|
deprecated: false,
|
|
insertText: label,
|
|
isSnippet: false,
|
|
replaceRange: null,
|
|
replaceRangeTab: null,
|
|
additionalEdits: [],
|
|
commitCharacters: [],
|
|
command: null,
|
|
data: null,
|
|
server: "kotlin",
|
|
});
|
|
window.__ipc.handlers.lsp_completion = () => ({
|
|
isIncomplete: false,
|
|
items: [item("alpha"), item("bravo"), item("charlie")],
|
|
});
|
|
});
|
|
await editor.locator(".cm-content").click();
|
|
await page.keyboard.press("Escape");
|
|
await page.keyboard.press("G");
|
|
await page.keyboard.press("o");
|
|
await expect(editor).toHaveAttribute("data-vim-mode", "insert");
|
|
await page.keyboard.press("Control+Space");
|
|
const popup = page.locator(".cm-tooltip-autocomplete");
|
|
const selected = popup.locator("li[aria-selected=true] .cm-completionLabel");
|
|
await expect(selected).toHaveText("alpha");
|
|
// CodeMirror ignores lookup moves in the first moments after it opens (interactionDelay).
|
|
await page.waitForTimeout(200);
|
|
await page.keyboard.press("Control+n");
|
|
await expect(selected).toHaveText("bravo");
|
|
await page.keyboard.press("Control+n");
|
|
await expect(selected).toHaveText("charlie");
|
|
await page.keyboard.press("Control+p");
|
|
await expect(selected).toHaveText("bravo");
|
|
await expect(editor).toHaveAttribute("data-vim-mode", "insert");
|
|
await expect(page.getByRole("dialog")).toHaveCount(0);
|
|
});
|
|
}
|