Use style-dependent colour to highlight errors#56
Conversation
|
Thanks for bringing up this issue, I agree that the error background color should not be hard coded. It is a pity that the pygments styles only specify one generic highlight color. I am not sure if it is a good idea to use the same color to highlight errors that is also used to highlight the current line however. Maybe one could do something similar to the highlighting of search results and modify the color a bit so it still fits the theme but is not the exact same: typstwriter/typstwriter/editor.py Line 1063 in 3e0ea19 Speaking of, the underline error color is also hard coded: typstwriter/typstwriter/editor.py Line 913 in 3e0ea19 Maybe the error token color could be appropriate for this one. |
Agreed For the main issue, I agree using the main highlight colour for different things isn't great, I forgot that you could highlight the current line. Alternatively, pygments themes do define a special line number font and background colour, so we could highlight only the line numbers (though since they are hideable, we would need a fallback either way). What do you think of that? Modifying the highlight colour would definitely work, but I'm not sure how easy it would be to make it look good with most themes, I'll need to experiment a bit. |
0b072be to
6b69dbb
Compare
|
@Bzero, I might look more closely at highlighting the line numbers, but I think a separate pull request would be more appropriate. |
|
Yes that sounds really good to me, that way we always get a red error color but with a brightness appropriate for the color theme. I think also highlighting the line numbers should not be necessary. |
Small typo.
|
Thanks a lot for this contribution! |


Previously, the error highlighting would make it near impossible to read the code when using a dark theme.
Unfortunately, pygments themes don't specify a colour for this specific purpose. The closest would be the error token colour, which however is meant to be used as a foreground colour. Using this would therefore mean to effectively loose the syntax highlighting on the affected lines, which is less than optimal.
My proposition would be to use the general highlight colour. While semantically less appropriate, it ensures that it remains readable with all themes.