Limit selection highlighting to within a single line and avoid crash
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
BackSpaceto 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.
I can't reproduce the original crash. Is there a sample file you can provide that reliably crashes?
@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.
@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.
@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.
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.
Closing in favour of #1470