Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/CodeEditTextView/STTextViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -223,6 +228,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
guard !hasSetStandardAttributes else { return }
hasSetStandardAttributes = true
textView.addAttributes(attributesFor(nil), range: .init(0..<textView.string.count))
highlighter?.invalidate()
}

/// Gets all attributes for the given capture including the line height, background color, and text color.
Expand Down