Revert "Playground: capture Ctrl+W as delete-previous-word"

This reverts commit b82f7b65fb.
This commit is contained in:
Sylvestre Ledru
2026-04-04 12:53:25 +02:00
parent b82f7b65fb
commit b00263738c
-19
View File
@@ -809,17 +809,6 @@ async function handleInput(data) {
continue;
}
if (code === 23) { // Ctrl+W — delete previous word
const before = inputBuffer.slice(0, cursorPos);
const after = inputBuffer.slice(cursorPos);
// Skip trailing spaces, then delete back to the previous space
const trimmed = before.replace(/\S+\s*$/, "");
cursorPos = trimmed.length;
inputBuffer = trimmed + after;
redrawInput();
continue;
}
if (code === 21) { // Ctrl+U
inputBuffer = "";
cursorPos = 0;
@@ -877,14 +866,6 @@ async function initPlayground(containerId) {
terminal.open(container);
fitAddon.fit();
// Prevent browser from closing the tab on Ctrl+W when the terminal is focused;
// xterm.js will receive it as code 23 and we handle it as "delete previous word".
container.addEventListener("keydown", (ev) => {
if (ev.ctrlKey && ev.key === "w") {
ev.preventDefault();
}
}, true);
window.addEventListener("resize", () => fitAddon.fit());
terminal.writeln("\x1b[1;38;5;166m _ _ _ _ _ _ _\x1b[0m");