Skip to content

Fix bold text flickering and theme switching on every view update#39

Open
tayl0r wants to merge 2 commits intoZeeZide:developfrom
tayl0r:develop
Open

Fix bold text flickering and theme switching on every view update#39
tayl0r wants to merge 2 commits intoZeeZide:developfrom
tayl0r:develop

Conversation

@tayl0r
Copy link

@tayl0r tayl0r commented Mar 21, 2026

Summary

  • Fix bold text flickering on every click/interaction: applyNewTheme(_:andFontSize:) was calling highlightr.setTheme(to:) on every SwiftUI view update even when the theme and font size hadn't changed. This caused the entire text storage to be re-highlighted, momentarily stripping and reapplying bold attributes and causing visible flicker. Added an early return when both the resolved theme name and font size are unchanged.

  • Fix theme not updating and track themeName correctly: applyNewTheme methods were not updating the stored themeName property after successfully applying a new theme. This meant the early-return guard couldn't correctly detect when a theme had changed, causing some theme switches (via settings) to silently fail. Added themeName = resolvedTheme after successful apply, and a guard themeName != oldValue in the didSet to prevent redundant double-application.

Test plan

  • Open a CodeEditor with fontSize binding and a theme set
  • Click repeatedly in the editor — bold text should remain stable (no flicker)
  • Change the theme programmatically — should apply immediately
  • Change it back — should apply without needing to close/reopen the editor

tayl0r and others added 2 commits March 19, 2026 14:00
applyNewTheme(_:andFontSize:) was calling highlightr.setTheme(to:) on
every SwiftUI view update even when the theme and font size hadn't
changed. This caused the entire text storage to be re-highlighted,
momentarily stripping and reapplying bold attributes and causing
visible flicker.

Add an early return when both the resolved theme name matches the
current theme and the font size is unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- applyNewTheme methods now update themeName after applying, so the
  early-return guard can correctly detect when theme hasn't changed
- didSet on themeName guards against redundant re-application when
  the value hasn't actually changed
- Fixes issue where switching themes in settings wouldn't always apply

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@helje5
Copy link
Member

helje5 commented Mar 21, 2026

That sounds good, can you also recommend a good cookie recipe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants