From b8979ea9ee3158961323e805795d90cf660cee93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 23 Feb 2026 23:27:33 +0800 Subject: [PATCH] Fix JSON highlighting lost after formatting config --- MacLibrary/CodeEditTextView.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MacLibrary/CodeEditTextView.swift b/MacLibrary/CodeEditTextView.swift index 04240f4..dcfcbde 100644 --- a/MacLibrary/CodeEditTextView.swift +++ b/MacLibrary/CodeEditTextView.swift @@ -128,6 +128,9 @@ struct CodeEditTextView: NSViewRepresentable { guard let controller = context.coordinator.controller else { return } if 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 { controller.configuration = makeConfiguration(isEditable: isEditable)