From 42f71388a2a2eaccfa68627165d6ae841ff69490 Mon Sep 17 00:00:00 2001 From: Ben Palmer Date: Wed, 18 Jan 2023 11:36:22 -0500 Subject: [PATCH 1/2] Add logic for ensuring attribute updates when font or baselineoffset are changed in preferences. --- Sources/CodeEditTextView/STTextViewController.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/CodeEditTextView/STTextViewController.swift b/Sources/CodeEditTextView/STTextViewController.swift index 7662dc377..9efd29f45 100644 --- a/Sources/CodeEditTextView/STTextViewController.swift +++ b/Sources/CodeEditTextView/STTextViewController.swift @@ -200,7 +200,12 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt /// Reloads the UI to apply changes to ``STTextViewController/font``, ``STTextViewController/theme``, ... internal func reloadUI() { - textView?.font = font + // if font or baseline has been modified, set the hasSetStandardAttributesFlag + // to false to ensure attributes are updated. This allows live UI updates when changing preferences. + if textView?.font != font || rulerView.baselineOffset != baselineOffset { + hasSetStandardAttributes = false + } + textView?.textColor = theme.text textView?.backgroundColor = theme.background textView?.insertionPointColor = theme.insertionPoint From ab08d016c7c55dc567e2c89931e9633313aeabb1 Mon Sep 17 00:00:00 2001 From: Ben Palmer Date: Wed, 18 Jan 2023 11:58:34 -0500 Subject: [PATCH 2/2] invalidate highlights after setting standard attributes. prevents zeroing of highlights --- Sources/CodeEditTextView/STTextViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/CodeEditTextView/STTextViewController.swift b/Sources/CodeEditTextView/STTextViewController.swift index 9efd29f45..d9479e02b 100644 --- a/Sources/CodeEditTextView/STTextViewController.swift +++ b/Sources/CodeEditTextView/STTextViewController.swift @@ -228,6 +228,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt guard !hasSetStandardAttributes else { return } hasSetStandardAttributes = true textView.addAttributes(attributesFor(nil), range: .init(0..