Remove DispatchQueue.main.async from all layout/rendering code paths

This commit is contained in:
jess 2026-04-07 14:19:40 -07:00
parent 3e52866825
commit 89aa999300
3 changed files with 15 additions and 35 deletions

View File

@ -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()
}
}
}

View File

@ -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(_:)) {

View File

@ -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