question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selecting text in highlighted code blocks unexpectedly hides certain contents

See original GitHub issue

Describe 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.

current

Expected behavior

Here is what I expected (I achieved this by removing the style rule in Material Darker)

expected

Here is how highlighting code via mouse works on Github, for example.

github_sample

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.

black_metal_burzum black_metal_burzum_expected

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:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
allejocommented, Oct 7, 2021

@highlightjs/core Any philosophical thoughts on whether a theme should be able to change selection color - as a matter of policy? If we wanted to be picky we could decide this “hurts usability” or violates the users choice in some way and just disallow it… but I think technically this can be fixed as I already mention above.

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 🤷‍♂️

0reactions
joshgoebelcommented, Oct 3, 2021

934f2e78 Should land in 11.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

1 Code::Blocks Project Management
This view show all the projects opened in Code::Blocks at a certain time. ... If you hold the Ctrl key and then select...
Read more >
c++ - Codeblocks variable highlighting... what's happened?
In Code::Blocks select Settings -> Editor -> Occurrences Highlighting (scroll down in the pane on the left side to find it) and then...
Read more >
obsidian-codemirror-options/README.md at main - GitHub
This setting creates consistent highlighting between edit and preview by using CodeMirror to highlight in both modes. Note: This setting requires the "Editor ......
Read more >
Code blocks in FigJam – Figma Help Center
Code blocks allow you to add formatted code as a movable object on the board and include syntax highlighting for several supported languages....
Read more >
2.6 R code chunks and inline R code | R Markdown - Bookdown
For example, you can choose hide text output via the chunk option results ... to merge text output and source code into a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found