fix: give native Quit its Command shortcut during text editing

This commit is contained in:
2026-10-12 15:18:42 +02:00
parent b2dc5fa373
commit 30cf85e880
5 changed files with 25 additions and 9 deletions
+11 -3
View File
@@ -125,8 +125,11 @@ def check_cli_instances(root, app, fixtures):
return (record["completion_eligible"] and record["duration_seconds"] is not None
and record["position_seconds"] / record["duration_seconds"] >= 0.95)
def quit_instance(pid, count):
write_request(pid, action="quit")
def quit_instance(pid, count, events=None):
if events is None:
write_request(pid, action="quit")
else:
write_request(pid, events=events)
deadline = time.monotonic() + 30
while time.monotonic() < deadline:
survivors = [json.loads(path.read_text()) for path in root.glob("state-*.json")
@@ -430,7 +433,12 @@ def check_cli_instances(root, app, fixtures):
wait_report(second_path, allowed_urls[1], lambda records: any(
progress_at(record, reported_urls[1], second_position) for record in records),
"second progress stream never receives first player's media identity")
quit_instance(second_reporter, total)
input_request(second_reporter, total, lambda state: state["editorText"] == "q",
"plain q remains text input rather than Quit",
events=[{"key": "q", "code": 12, "editing": True}])
quit_instance(second_reporter, total, events=[
{"key": "q", "code": 12, "flags": 1 << 20, "editing": True, "queued": True},
])
final_second = wait_report(second_path, allowed_urls[1], lambda records: (
records[-1]["event"] == "closed"
and abs(records[-1]["position_seconds"] - second_position) < 0.5) if records else False,
+3 -1
View File
@@ -184,8 +184,10 @@ private enum CLIInstanceCheck {
if let menu = NSApp.mainMenu { prepareMenu(menu) }
precondition(NSApp.mainMenu?.performKeyEquivalent(with: event) == true,
"Configured shortcut must be accepted by the native menu")
} else if input["queued"] as? Bool == true {
NSApp.postEvent(event, atStart: false)
} else { NSApp.sendEvent(event) }
if input["editing"] as? Bool == true {
if input["editing"] as? Bool == true && input["queued"] as? Bool != true {
editorText = editor.string
window.makeFirstResponder(nil)
editor.removeFromSuperview()