-
Notifications
You must be signed in to change notification settings - Fork 270
Description
Description
The + and - keys for resizing the console window do not work reliably. The issue is intermittent and depends on the terminal emulator and keyboard protocol in use.
Root Cause Analysis
The key handling in packages/core/src/console.ts (lines 480-485) checks:
} else if (event.name === "+" || (event.name === "=" && event.shift)) {
this.options.sizePercent = Math.min(100, this.options.sizePercent + 5)
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
} else if (event.name === "-") {Issues identified:
-
Kitty keyboard protocol inconsistency: When Kitty protocol is enabled, terminals may send the base key codepoint (
=with shift modifier) rather than the shifted result (+). Inparse.keypress-kitty.ts,key.nameis set fromString.fromCodePoint(codepoint)and the shifted codepoint only updatestext, notkey.name. -
US keyboard layout assumption: The
+key requires Shift+= on US keyboards. Different terminals handle this differently:- Raw mode: Sends literal
+character - Kitty protocol: May send codepoint 61 (
=) with shift flag, or codepoint 43 (+)
- Raw mode: Sends literal
-
No keypad support: Numeric keypad
+and-keys (codes 57413/57414 in Kitty) are mapped tokpminus/kpplusbut not handled by the console.
Suggested Fix
Normalize key detection to handle all variants:
const isPlus = event.name === "+" ||
(event.name === "=" && event.shift) ||
event.name === "kpplus"
const isMinus = event.name === "-" ||
event.name === "kpminus"
if (isPlus) {
this.options.sizePercent = Math.min(100, this.options.sizePercent + 5)
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
} else if (isMinus) {
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5)
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
}Environment
- Affected file:
packages/core/src/console.ts - Related files:
packages/core/src/lib/parse.keypress.ts,packages/core/src/lib/parse.keypress-kitty.ts