fix(window): keep window commands typed after timeoutlen in vscode

Once 'timeoutlen' passes after a lone <C-w>, nvim runs its builtin window
command, which reads the next key without mappings, so the vscode window
mappings were skipped (e.g. <C-w>c closed the nvim window instead of the
editor).

Map a lone <C-w> to read the next key and feed the whole command again,
with its count, remapped when one of the window mappings handles it
(special keys like <C-w><C-Down> included).

Fixes #2466
This commit is contained in:
dualfroz committed 2026-10-03 02:24:35 +02:00
1 parent 17cff16264
commit 955555921e
2 files changed
+28 -1

No files matched your search

@@ -6,7 +6,7 @@ import { strict as assert } from "assert";
import vscode, { Selection } from "vscode";
import { NeovimClient } from "neovim";
import { wait } from "../../utils";
import { wait, waitUntil } from "../../utils";
import {
attachTestNvimClient,
@@ -345,6 +345,22 @@ describe("VSCode integration specific stuff", () => {
);
});
it("Window commands typed after timeoutlen still go to vscode #2466", async () => {
await openTextDocument({ content: "blah" });
const timeoutlen = (await client.getOption("timeoutlen")) as number;
await client.setOption("timeoutlen", 100);
try {
await sendNeovimKeys(client, "<C-w>", 500);
await sendNeovimKeys(client, "v");
await waitUntil(() =>
assert.equal(vscode.window.tabGroups.all.length, 2, "<C-w>v should split the editor"),
);
} finally {
await client.setOption("timeoutlen", timeoutlen);
await vscode.commands.executeCommand("workbench.action.joinAllGroups");
}
});
it("Opens a file through e command", async () => {
const filePath = path.join(os.tmpdir(), Math.random().toString());
fs.writeFileSync(filePath, ["line 1"].join("\n"), {