Selecting text in highlighted code blocks unexpectedly hides certain contents
See original GitHub issueDescribe the issue/behavior that seems buggy
By default, in the base-16 themes, highlighting text (in the click and drag sense) hides some of the code. The problem is caused by the .hljs ::selection
css rules in the files. It seems like they should be deleted.
Sample Code or Instructions to Reproduce
Try highlighting the code in this jsfiddle, which loads Material Darker.
Here’s a screenshot for what it looks like for Material Darker.
Expected behavior
Here is what I expected (I achieved this by removing the style rule in Material Darker)
Here is how highlighting code via mouse works on Github, for example.
Here is how it looks on other base 16 themes. This one is Black Metal Burzum. The second picture is what happened when I removed the css rule from the browser files.
Additional context
This is a very good and widely used project, so perhaps this is on purpose and I hope I am not misunderstanding something. However, code tends to be highlighted/selected for the purpose of copying to the clipboard, so if you are user and are trying to select up to say a specific character of text, it becomes a poor user experience if some of if it randomly disappears/becomes hard to see.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
I, personally, would allow themes to change selection color. Yes, it can lead to usability issues but there’s also a chance that the browser color for highlighting can conflict with the theme. I don’t think existing themes should be changed to add a selection color but if there’s a problem with it, then it can be fixed.
If you’re a theme author and you want to torture everyone by having red on green, we won’t stop you; just nobody will use your theme 🤷♂️
934f2e78 Should land in 11.3