CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

🐞 Changing Theme Bug

Open lukepistrol opened this issue 2 years ago • 4 comments

Description

Under certain circumstances changing a theme will not change the code highlighting in the editor (see attached video). The background of the text will change accordingly though.

To Reproduce

  1. Open App Preferences
  2. Change the App Appearance
  3. Change the Theme

Workaround:

  • Close all open files and reopen them.
  • or restart the app.

Expected behavior

The highlighted text should change to the colors of the selected theme

Version information

Hash: 45ab3bd64ee9e5c50573538e31fe948ba8514bc3 MacOS: 12.3.1 Xcode: 13.3

Additional context

Screen Recording

https://user-images.githubusercontent.com/9460130/165387222-7b7d555d-76c0-45ca-bf7c-cc921f57aa5c.mov

Notes:

Themes are applied in CodeEditModules/Modules/CodeFile/src/CodeEditor.swift.

The themeString changes correctly on theme selection.

lukepistrol avatar Apr 26 '22 20:04 lukepistrol

Maybe there's a problem with the package we're using to initialize the themes (Highlightr). I looked through the workspace and traced back to the file were the problem began... looks like the following lines of code should be reviewed. I'll do it later.

highlightr?.setTheme(theme: .init(themeString: themeString))
if prefs.preferences.textEditing.font.customFont {
  highlightr?.theme.codeFont = .init(
    name: prefs.preferences.textEditing.font.name,
    size: CGFloat(prefs.preferences.textEditing.font.size)
  )
} else {
  highlightr?.theme.codeFont = .monospacedSystemFont(ofSize: 11, weight: .medium)
}
  • [ ] Review the code
  • [ ] Review the package (Highlightr)
  • [ ] Fix the bug 🎉

ghost avatar May 15 '22 14:05 ghost

@SwiftUILabs We are currently working on an editor based on tree-sitter instead of Highlightr.js. This should be fixed when we get that in place.

austincondiff avatar May 16 '22 17:05 austincondiff

@austincondiff Perfect. Hopefully it won't be too hard to migrate from Highlightr.js

ghost avatar May 17 '22 15:05 ghost

@SwiftUILabs: Unfortunately tree-sitter is a very complex topic and implementing it requires a lot of things to be figured out beforehand. So this will take some time.

lukepistrol avatar May 18 '22 01:05 lukepistrol

I would like to work on this issue. Can you please assign this to me

amit-srt avatar Sep 02 '22 21:09 amit-srt

Closing this. I believe this was fixed by @thecoolwinter.

austincondiff avatar Sep 14 '22 14:09 austincondiff