code icon indicating copy to clipboard operation
code copied to clipboard

Limit selection highlighting to within a single line and avoid crash

Open jeremypw opened this issue 1 year ago • 3 comments

Fixes #1443

To reproduce issue:

  • Load a (disposable) document with many lines and with repeated lines.
  • Ensure the "Highlight selection" plugin is active
  • Click at start of a repeated line
  • Press <Shift>Down (The repeated line is selected and highlighted)
  • Press BackSpace to delete the highlighted line
  • Code crashes after a short pause

This PR stops the highlight word selection plugin highlighting selections covering more than one line as deleting such selections with BackSpace causes a crash. The exact cause of the crash was not determined as it did not yield a useful backtrace.

Also, in passing, the current search context is cancelled earlier when the selection changes.

jeremypw avatar Jul 05 '24 14:07 jeremypw

I can't reproduce the original crash. Is there a sample file you can provide that reliably crashes?

danirabbit avatar Jul 24 '24 16:07 danirabbit

@danirabbit It did not seem particularly difficult to reproduce the crash provided the recipe above is followed - the important thing is that the selection includes the line ending and there are multiple highlights. I'll push a file in a minute though.

jeremypw avatar Jul 27 '24 18:07 jeremypw

@danirabbit Try this file. Place the cursor at the beginning of (e.g) Stack trace of thread 2085: then press <Shift><Down> to select the whole line (including the CR/LF). Several similar line should highlight. Press BackSpace. Code crashes.

Make sure you have the master version installed (as the it is a plugin problem) and have the highlighting extension active.

CodeDeleteTest.txt

jeremypw avatar Jul 27 '24 18:07 jeremypw

@danirabbit Yes, its difficult to fix properly when the cause is obscure. Must some kind of race I guess - I can reliably reproduce on my system and the fix seem reliable here too.

I'll convert to draft pending the cause being identified better.

jeremypw avatar Sep 05 '24 15:09 jeremypw

This did not fix it for me. It is odd, it doesn't seem to be even hitting the plug-in code before it crashes, so this may be an issue with gtksourceview.

zeebok avatar Sep 20 '24 00:09 zeebok

Closing in favour of #1470

jeremypw avatar Oct 07 '24 19:10 jeremypw