Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 8 commits into from

Conversation

jeremypw
Copy link
Collaborator

@jeremypw jeremypw commented Jul 5, 2024

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 jeremypw marked this pull request as ready for review July 18, 2024 16:19
@jeremypw jeremypw requested a review from a team July 18, 2024 16:19
@jeremypw jeremypw changed the title Limit selection highlighting to single line and avoid crash Limit selection highlighting to within a single line and avoid crash Jul 18, 2024
@danirabbit
Copy link
Member

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

@jeremypw
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

@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

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, so I can still reproduce the crash if I select a line by double clicking it, but only sometimes. I can't find good reproduction conditions.

But also, this breaks highlighting matches when selecting with the keyboard

So I dunno about this fix. It seems to only stop crashing sometimes and it breaks the functionality of the plugin, but also only sometimes

@jeremypw
Copy link
Collaborator Author

jeremypw commented Sep 5, 2024

@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 jeremypw marked this pull request as draft September 5, 2024 15:52
@zeebok
Copy link
Contributor

zeebok commented Sep 20, 2024

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.

@jeremypw
Copy link
Collaborator Author

jeremypw commented Oct 7, 2024

Closing in favour of #1470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code crashes when deleting lines
3 participants