From 1ee2083f9b87098f6b3cacc08dca2f946a96d6ed Mon Sep 17 00:00:00 2001 From: ksqsf Date: Mon, 9 Sep 2024 20:33:18 +0200 Subject: [PATCH] fix: create sessions for empty app bundle identifiers Closes #977 --- sources/SquirrelInputController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/SquirrelInputController.swift b/sources/SquirrelInputController.swift index 3b4861a11..370d01ef6 100644 --- a/sources/SquirrelInputController.swift +++ b/sources/SquirrelInputController.swift @@ -9,6 +9,7 @@ import InputMethodKit final class SquirrelInputController: IMKInputController { private static let keyRollOver = 50 + private static var unknownAppCnt: UInt = 0 private weak var client: IMKTextInput? private let rimeAPI: RimeApi_stdbool = rime_get_api_stdbool().pointee @@ -332,7 +333,10 @@ private extension SquirrelInputController { } func createSession() { - guard let app = client?.bundleIdentifier() else { return } + let app = client?.bundleIdentifier() ?? { + SquirrelInputController.unknownAppCnt &+= 1 + return "UnknownApp\(SquirrelInputController.unknownAppCnt)" + }() print("createSession: \(app)") currentApp = app session = rimeAPI.create_session()