Fix JSON highlighting lost after formatting config

This commit is contained in:
世界
2026-02-23 23:27:33 +08:00
parent 015dcd266b
commit b8979ea9ee
+3
View File
@@ -128,6 +128,9 @@ struct CodeEditTextView: NSViewRepresentable {
guard let controller = context.coordinator.controller else { return } guard let controller = context.coordinator.controller else { return }
if controller.text != text { if controller.text != text {
controller.text = text controller.text = text
// setText() creates a new Highlighter but doesn't trigger initial highlighting.
// Re-setting the language forces the highlighter to invalidate and re-highlight.
controller.language = .json
} }
if controller.configuration.behavior.isEditable != isEditable { if controller.configuration.behavior.isEditable != isEditable {
controller.configuration = makeConfiguration(isEditable: isEditable) controller.configuration = makeConfiguration(isEditable: isEditable)