CodeEdit
CodeEdit copied to clipboard
🐞 Changing Theme Bug
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
- Open App Preferences
- Change the App Appearance
- 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.
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 🎉
@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 Perfect. Hopefully it won't be too hard to migrate from Highlightr.js
@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.
I would like to work on this issue. Can you please assign this to me
Closing this. I believe this was fixed by @thecoolwinter.