Skip to content

Commit 0b82a06

Browse files
authored
core: compact keypress debug output and add IME repro (#941)
Rework the keypress debug demo around parsed events instead of large per-event cards. Keep the main feed dense, move raw input into session detail and export output, and show the latest event with useful fields such as source, code, and Kitty baseCode. Add test that reproduces Ctrl+C when Kitty reports an alternate base layout for a non-Latin IME. For anomalyco/opencode#21163
1 parent 1ba7364 commit 0b82a06

16 files changed

Lines changed: 972 additions & 337 deletions

‎packages/core/src/console.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,23 @@ describe("TerminalConsole", () => {
315315
expect(onCopy).toHaveBeenCalledWith("Hello")
316316
})
317317

318+
test("should use baseCode for Ctrl+Shift+C from alternate layouts", () => {
319+
const onCopy = mock(() => {})
320+
terminalConsole = new TerminalConsole(mockRenderer as any, {
321+
position: ConsolePosition.BOTTOM,
322+
sizePercent: 30,
323+
onCopySelection: onCopy,
324+
})
325+
326+
terminalConsole["_displayLines"] = [{ text: "Hello World", level: "LOG" as any, indent: false }]
327+
terminalConsole["_selectionStart"] = { line: 0, col: 0 }
328+
terminalConsole["_selectionEnd"] = { line: 0, col: 5 }
329+
330+
terminalConsole["handleKeyPress"]({ name: "ㅊ", baseCode: 99, ctrl: true, shift: true, meta: false } as any)
331+
332+
expect(onCopy).toHaveBeenCalledWith("Hello")
333+
})
334+
318335
test("should not trigger when no selection", () => {
319336
const onCopy = mock(() => {})
320337
terminalConsole = new TerminalConsole(mockRenderer as any, {

‎packages/core/src/console.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import type { KeyEvent } from "./lib/KeyHandler.js"
1515
import {
1616
type KeyBinding as BaseKeyBinding,
1717
mergeKeyBindings,
18-
getKeyBindingKey,
1918
buildKeyBindingsMap,
19+
getKeyBindingAction,
2020
type KeyAliasMap,
2121
defaultKeyAliases,
2222
mergeKeyAliases,
@@ -516,16 +516,7 @@ export class TerminalConsole extends EventEmitter {
516516
return
517517
}
518518

519-
const bindingKey = getKeyBindingKey({
520-
name: event.name,
521-
ctrl: event.ctrl,
522-
shift: event.shift,
523-
meta: event.meta,
524-
super: event.super,
525-
action: "scroll-up" as ConsoleAction,
526-
})
527-
528-
const action = this._keyBindingsMap.get(bindingKey)
519+
const action = getKeyBindingAction(this._keyBindingsMap, event)
529520

530521
if (action) {
531522
const handler = this._actionHandlers.get(action)

0 commit comments

Comments
 (0)