Skip to content

Commit 2913426

Browse files
ZhaoChaoqunclaude
andcommitted
fix: prevent recording state machine deadlock on trigger key change
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d479112 commit 2913426

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Sources/KeyMonitor.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class KeyMonitor {
164164
/// ⚠️ 必须通过 DispatchQueue.main.async 异步调用,禁止在 CGEvent tap 回调中同步调用,
165165
/// 因为 stopMonitoring() 会销毁当前正在执行回调的 event tap,导致未定义行为。
166166
func restartWithNewTriggerKey() {
167+
if isTriggerPressed {
168+
onKeyUp?()
169+
}
167170
stopMonitoring()
168171
isTriggerPressed = false
169172
triggerConfig = .current

0 commit comments

Comments
 (0)