uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.63k stars 130 forks source link

Bug: Highlighting selection on active line doesn't work #406

Closed notmedia closed 1 year ago

notmedia commented 1 year ago

Hi! The problem here is that when you setup selection color it doesn't highlight selection on active line. For default theme it works.

In this example I selected '#4D4D4C', string, you can see that match selection worked.

Screenshot 2022-11-14 at 00 56 21
jaywcjlove commented 1 year ago
image

https://github.com/uiwjs/react-codemirror/blob/09521ddade2b3ebc86811f6e006dece0182c79aa/www/src/pages/theme/editor/index.tsx#L75-L86

@notmedia I found no errors.

notmedia commented 1 year ago

@jaywcjlove Hey! Try to select text on active line, you may see that selection is invisible there

jaywcjlove commented 1 year ago

I fixed it. @notmedia Upgrade v4.14.2

notmedia commented 1 year ago

@jaywcjlove Hi! Thank you, but I found another bug here. If you define selection color and lineHighlight color then selection is also invisible on active line. So the lineHighlight overrides it.

image
jaywcjlove commented 1 year ago

https://codesandbox.io/embed/codemirror-uiwjs-react-codemirror-issues-406-s6m8mc?fontsize=14&hidenavigation=1&theme=dark

I created a new codemirror example to test it. Looks fine.

selection word, lineHighlight hides

Maybe I didn't understand your question.

@notmedia

notmedia commented 1 year ago

@jaywcjlove I took a video

https://user-images.githubusercontent.com/12993018/202718554-fce09d90-d443-43e9-aae3-6796ca1a1fb9.mov

jaywcjlove commented 1 year ago

image

I understand, I see the official solution is to set the transparent background color.

@notmedia

notmedia commented 1 year ago

@jaywcjlove But on official webpage it works as expected(

https://user-images.githubusercontent.com/12993018/202728218-f5b5231e-2b96-41d9-b251-c20f760cd685.mov

jaywcjlove commented 1 year ago
image

@notmedia using a transparent color

notmedia commented 1 year ago

@jaywcjlove Yeah, it works! Thank you :)

elitenas commented 1 year ago

I think the bug here is that if the text is selected... the activeLine class should be removed. This bug was introduced after 4.11.6

notmedia commented 1 year ago

No, because you need to see active line in selection if you select multiple lines

elitenas commented 1 year ago

if we set activeLine to transparent to see the highlight or selection then we dont see which line is active ever