diff --git a/src/CompositorView.swift b/src/CompositorView.swift index d1d5e32..d2cec3b 100644 --- a/src/CompositorView.swift +++ b/src/CompositorView.swift @@ -815,10 +815,8 @@ struct CompositorRepresentable: NSViewRepresentable { ] updateBlockRanges(for: textView) - DispatchQueue.main.async { - context.coordinator.triggerImageUpdate() - context.coordinator.triggerTableUpdate() - } + context.coordinator.triggerImageUpdate() + context.coordinator.triggerTableUpdate() return scrollView } @@ -835,9 +833,7 @@ struct CompositorRepresentable: NSViewRepresentable { } textView.selectedRanges = selectedRanges updateBlockRanges(for: textView) - DispatchQueue.main.async { - context.coordinator.triggerTableUpdate() - } + context.coordinator.triggerTableUpdate() } textView.backgroundColor = Theme.current.base textView.insertionPointColor = Theme.current.text @@ -938,18 +934,14 @@ struct CompositorRepresentable: NSViewRepresentable { updateBlockRanges(for: tv) tv.needsDisplay = true - DispatchQueue.main.async { [weak self] in - self?.updateInlineImages() - self?.updateEmbeddedTables() - } + updateInlineImages() + updateEmbeddedTables() } func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { if commandSelector == #selector(NSResponder.insertNewline(_:)) { insertNewlineWithAutoIndent(textView) - DispatchQueue.main.async { [weak self] in - self?.parent.onEvaluate() - } + parent.onEvaluate() return true } if commandSelector == #selector(NSResponder.deleteBackward(_:)) { @@ -1414,9 +1406,7 @@ struct CompositorRepresentable: NSViewRepresentable { updateBlockRanges(for: tv) isUpdatingTables = false - DispatchQueue.main.async { [weak self] in - self?.updateEmbeddedTables() - } + updateEmbeddedTables() } } } diff --git a/src/EditorView.swift b/src/EditorView.swift index 094a830..4a37932 100644 --- a/src/EditorView.swift +++ b/src/EditorView.swift @@ -1174,10 +1174,8 @@ struct EditorTextView: NSViewRepresentable { ] updateBlockRanges(for: textView) - DispatchQueue.main.async { - context.coordinator.triggerImageUpdate() - context.coordinator.triggerTableUpdate() - } + context.coordinator.triggerImageUpdate() + context.coordinator.triggerTableUpdate() return scrollView } @@ -1293,18 +1291,14 @@ struct EditorTextView: NSViewRepresentable { updateBlockRanges(for: tv) tv.needsDisplay = true - DispatchQueue.main.async { [weak self] in - self?.updateInlineImages() - self?.updateEmbeddedTables() - } + updateInlineImages() + updateEmbeddedTables() } func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { if commandSelector == #selector(NSResponder.insertNewline(_:)) { insertNewlineWithAutoIndent(textView) - DispatchQueue.main.async { [weak self] in - self?.parent.onEvaluate() - } + parent.onEvaluate() return true } if commandSelector == #selector(NSResponder.deleteBackward(_:)) { diff --git a/src/SettingsView.swift b/src/SettingsView.swift index a90f1ba..01cbf95 100644 --- a/src/SettingsView.swift +++ b/src/SettingsView.swift @@ -76,16 +76,12 @@ struct SettingsView: View { .background(Color(ns: palette.base)) .onChange(of: themeMode) { ConfigManager.shared.themeMode = themeMode - DispatchQueue.main.async { - applyThemeAppearance() - NotificationCenter.default.post(name: .settingsChanged, object: nil) - } + applyThemeAppearance() + NotificationCenter.default.post(name: .settingsChanged, object: nil) } .onChange(of: lineIndicatorMode) { ConfigManager.shared.lineIndicatorMode = lineIndicatorMode - DispatchQueue.main.async { - NotificationCenter.default.post(name: .settingsChanged, object: nil) - } + NotificationCenter.default.post(name: .settingsChanged, object: nil) } .onChange(of: autoSaveDir) { ConfigManager.shared.autoSaveDirectory = autoSaveDir