fix: choose the insertion route on the main actor (crash on background thread)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,12 +12,11 @@ import SwiftUI
|
||||
final class InsertionPolicy {
|
||||
var windowSession = false
|
||||
|
||||
@MainActor
|
||||
func route() -> InsertionRoute {
|
||||
MainActor.assumeIsolated {
|
||||
let sstInFront = NSWorkspace.shared.frontmostApplication?.bundleIdentifier == Bundle.main.bundleIdentifier
|
||||
if sstInFront { return NoteEditorRegistry.shared.active != nil ? .editor : .none }
|
||||
return windowSession ? .none : .system
|
||||
}
|
||||
let sstInFront = NSWorkspace.shared.frontmostApplication?.bundleIdentifier == Bundle.main.bundleIdentifier
|
||||
if sstInFront { return NoteEditorRegistry.shared.active != nil ? .editor : .none }
|
||||
return windowSession ? .none : .system
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +102,7 @@ final class AppModel: ObservableObject {
|
||||
inserter: RoutingInserter(
|
||||
system: TextInserter(pasteboard: SystemPasteboard(), paster: CGEventPaster()),
|
||||
editor: EditorInserter(),
|
||||
route: { policy.route() }),
|
||||
route: { await policy.route() }),
|
||||
corrector: corrector,
|
||||
vocabularyProvider: { settings.usePriming ? VocabularyBuilder.build(from: dictionary.entries) : [] })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user