Remove DispatchQueue.main.async from all layout/rendering code paths
This commit is contained in:
parent
3e52866825
commit
89aa999300
|
|
@ -815,10 +815,8 @@ struct CompositorRepresentable: NSViewRepresentable {
|
||||||
]
|
]
|
||||||
updateBlockRanges(for: textView)
|
updateBlockRanges(for: textView)
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
context.coordinator.triggerImageUpdate()
|
context.coordinator.triggerImageUpdate()
|
||||||
context.coordinator.triggerTableUpdate()
|
context.coordinator.triggerTableUpdate()
|
||||||
}
|
|
||||||
|
|
||||||
return scrollView
|
return scrollView
|
||||||
}
|
}
|
||||||
|
|
@ -835,10 +833,8 @@ struct CompositorRepresentable: NSViewRepresentable {
|
||||||
}
|
}
|
||||||
textView.selectedRanges = selectedRanges
|
textView.selectedRanges = selectedRanges
|
||||||
updateBlockRanges(for: textView)
|
updateBlockRanges(for: textView)
|
||||||
DispatchQueue.main.async {
|
|
||||||
context.coordinator.triggerTableUpdate()
|
context.coordinator.triggerTableUpdate()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
textView.backgroundColor = Theme.current.base
|
textView.backgroundColor = Theme.current.base
|
||||||
textView.insertionPointColor = Theme.current.text
|
textView.insertionPointColor = Theme.current.text
|
||||||
textView.typingAttributes = [
|
textView.typingAttributes = [
|
||||||
|
|
@ -938,18 +934,14 @@ struct CompositorRepresentable: NSViewRepresentable {
|
||||||
updateBlockRanges(for: tv)
|
updateBlockRanges(for: tv)
|
||||||
tv.needsDisplay = true
|
tv.needsDisplay = true
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
updateInlineImages()
|
||||||
self?.updateInlineImages()
|
updateEmbeddedTables()
|
||||||
self?.updateEmbeddedTables()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||||
insertNewlineWithAutoIndent(textView)
|
insertNewlineWithAutoIndent(textView)
|
||||||
DispatchQueue.main.async { [weak self] in
|
parent.onEvaluate()
|
||||||
self?.parent.onEvaluate()
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if commandSelector == #selector(NSResponder.deleteBackward(_:)) {
|
if commandSelector == #selector(NSResponder.deleteBackward(_:)) {
|
||||||
|
|
@ -1414,9 +1406,7 @@ struct CompositorRepresentable: NSViewRepresentable {
|
||||||
updateBlockRanges(for: tv)
|
updateBlockRanges(for: tv)
|
||||||
isUpdatingTables = false
|
isUpdatingTables = false
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
updateEmbeddedTables()
|
||||||
self?.updateEmbeddedTables()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1174,10 +1174,8 @@ struct EditorTextView: NSViewRepresentable {
|
||||||
]
|
]
|
||||||
updateBlockRanges(for: textView)
|
updateBlockRanges(for: textView)
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
context.coordinator.triggerImageUpdate()
|
context.coordinator.triggerImageUpdate()
|
||||||
context.coordinator.triggerTableUpdate()
|
context.coordinator.triggerTableUpdate()
|
||||||
}
|
|
||||||
|
|
||||||
return scrollView
|
return scrollView
|
||||||
}
|
}
|
||||||
|
|
@ -1293,18 +1291,14 @@ struct EditorTextView: NSViewRepresentable {
|
||||||
updateBlockRanges(for: tv)
|
updateBlockRanges(for: tv)
|
||||||
tv.needsDisplay = true
|
tv.needsDisplay = true
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
updateInlineImages()
|
||||||
self?.updateInlineImages()
|
updateEmbeddedTables()
|
||||||
self?.updateEmbeddedTables()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||||
insertNewlineWithAutoIndent(textView)
|
insertNewlineWithAutoIndent(textView)
|
||||||
DispatchQueue.main.async { [weak self] in
|
parent.onEvaluate()
|
||||||
self?.parent.onEvaluate()
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if commandSelector == #selector(NSResponder.deleteBackward(_:)) {
|
if commandSelector == #selector(NSResponder.deleteBackward(_:)) {
|
||||||
|
|
|
||||||
|
|
@ -76,17 +76,13 @@ struct SettingsView: View {
|
||||||
.background(Color(ns: palette.base))
|
.background(Color(ns: palette.base))
|
||||||
.onChange(of: themeMode) {
|
.onChange(of: themeMode) {
|
||||||
ConfigManager.shared.themeMode = themeMode
|
ConfigManager.shared.themeMode = themeMode
|
||||||
DispatchQueue.main.async {
|
|
||||||
applyThemeAppearance()
|
applyThemeAppearance()
|
||||||
NotificationCenter.default.post(name: .settingsChanged, object: nil)
|
NotificationCenter.default.post(name: .settingsChanged, object: nil)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.onChange(of: lineIndicatorMode) {
|
.onChange(of: lineIndicatorMode) {
|
||||||
ConfigManager.shared.lineIndicatorMode = 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) {
|
.onChange(of: autoSaveDir) {
|
||||||
ConfigManager.shared.autoSaveDirectory = autoSaveDir
|
ConfigManager.shared.autoSaveDirectory = autoSaveDir
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue