From ace5e370a49fe2937a5475a269eaea8f89309cd5 Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Fri, 20 Dec 2024 07:38:56 -0500 Subject: [PATCH] Restore selection workaround for rendering attributes --- Sources/Glyph/NSTextView+Additions.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sources/Glyph/NSTextView+Additions.swift b/Sources/Glyph/NSTextView+Additions.swift index 14db757..c927bc9 100644 --- a/Sources/Glyph/NSTextView+Additions.swift +++ b/Sources/Glyph/NSTextView+Additions.swift @@ -62,8 +62,22 @@ extension TextView { return } + // apply a workaround to force rendering attributes to be applied immediately +#if os(macOS) + let selection = self.selectedRanges +#else + let selection = self.selectedRange +#endif + textLayoutManager.setRenderingAttributes(attributes, for: textRange) +#if os(macOS) + self.selectedRanges = [NSValue(range: range)] + self.selectedRanges = selection +#else + self.selectedRange = range + self.selectedRange = selection +#endif return }