elementary / code

Code editor designed for elementary OS
https://elementary.io
GNU General Public License v3.0
472 stars 112 forks source link

Limit selection highlighting to within a single line and avoid crash #1447

Open jeremypw opened 2 months ago

jeremypw commented 2 months ago

Fixes #1443

To reproduce issue:

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.

danirabbit commented 2 months ago

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

jeremypw commented 2 months ago

@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 commented 2 months ago

@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 commented 3 weeks ago

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

zeebok commented 1 week ago

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.