From d087a065c2c2c954b18ead85a8157483c3628580 Mon Sep 17 00:00:00 2001 From: wangzhizhou <824219521@qq.com> Date: Sat, 7 Nov 2026 18:07:55 +0800 Subject: [PATCH] chore: log option key dispatch when diagnostics are enabled The option-L chord still reaches the document while punctuation and variant chords are consumed, and the two paths we intercept are both in the controller, so the next step is evidence rather than another guess. With the hud-diag switch present the controller now records every option keyDown with its raw and ignoring-modifier characters, its flags and whether the learning chord matched, plus every inputText delivery and the event behind it. Signed-off-by: wangzhizhou <824219521@qq.com> --- platforms/macos/Sources/InputController.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platforms/macos/Sources/InputController.swift b/platforms/macos/Sources/InputController.swift index 826c9b9..c46029b 100644 --- a/platforms/macos/Sources/InputController.swift +++ b/platforms/macos/Sources/InputController.swift @@ -541,6 +541,10 @@ final class LampyrisInputController: IMKInputController { /// 没有组合态时,IMK 会把带 Option 的按键当"文本"直接交给默认实现(于是文档里出现 ¬)。 /// 这里先拦热键,其它文本原样交给系统。 override func inputText(_ string: String!, client sender: Any!) -> Bool { + if Self.hudDiagEnabled { + let event = NSApp.currentEvent + Self.hudDiag("inputText text=\(string ?? "-") event=\(event.map { "\($0.type.rawValue):\($0.characters ?? "-")" } ?? "nil")") + } if let event = NSApp.currentEvent, event.type == .keyDown, handleHotkey(event, sender: sender) { return true } @@ -583,6 +587,11 @@ final class LampyrisInputController: IMKInputController { } return false } + if Self.hudDiagEnabled, event.type == .keyDown, event.modifierFlags.contains(.option) { + Self.hudDiag("keydown chars=\(event.characters ?? "-") ignore=\(event.charactersIgnoringModifiers ?? "-")" + + " flags=\(event.modifierFlags.rawValue) learning=" + + "\(session?.matches("hotkey.toggle_wubi_learning", event) ?? false)") + } if event.type == .keyDown, handleHotkey(event, sender: sender) { return true } guard event.type == .keyDown, let session, let client = sender as? IMKTextInput else { return false