Skip to content

fix: bad selections on delete.#2750

Open
paxcut wants to merge 2 commits into
masterfrom
fix/issue_2748
Open

fix: bad selections on delete.#2750
paxcut wants to merge 2 commits into
masterfrom
fix/issue_2748

Conversation

@paxcut
Copy link
Copy Markdown
Collaborator

@paxcut paxcut commented May 30, 2026

This attempts to fix the problems described in issue #2748. When a selection is deleted, the selection ends are changed correctly, but the interactive selection is not so attempting to use it after the deletion produces unexpected results.

The fix is to update the interactive selection as well. I also made some code more efficient by removing the creation of temporary objects that were not necessary. Some code was repeated several times, so I move the code into their own function. Cleaned the code handling mouse clicks and added some using typedefs to shorten code.

This attempts to fix the problems described in issue 2748. When a selection is deleted, the selection ends are changed correctly, but the interactive selection is not so attempting to use it after the deletion produces unexpected results.

The fix is to update the interactive selection as well. I also made some code more efficient by removing the creation of temporary objects that were not necessary.
Some code was repeated several times, so I move the code into their own function.
Cleaned the code handling mouse clicks and added some `using` typedefs to shorten code.
@yuriks
Copy link
Copy Markdown

yuriks commented May 31, 2026

Tested the PR build and can confirm it fixes the selection shifting bug for me!

However... it seems to break text editing in other ways. For example, opening a new file, then pressing Ctrl-A to select the default comment text, then pressing backspace does not successfully delete it, just clearing the selection instead. However, I can then press Ctrl-Z and imhex inserts back a copy of the file, so it seems like it did think it deleted that text although it failed to do so. I'm going to install the previous build I was using just to confirm it's actually a regression.

@yuriks
Copy link
Copy Markdown

yuriks commented May 31, 2026

Can confirm the issue I mentioned above doesn't happen on the latest CI build of the master branch.

I appreciate your patience with these. I feel kinda bad that even after you quickly fix one issue, I end up immediately finding a different one. These are in no way urgent for me so feel free to prioritize other work if you want to.

@paxcut
Copy link
Copy Markdown
Collaborator Author

paxcut commented May 31, 2026

I really have nothing but appreciation for all the time you are spending on making ImHex a better hex editor regardless of how much you are or are not enjoying yourself while doing it. From your perspective, finding these bugs is easier than fixing them but from my perspective it is the opposite. As evidence to that I think I have fixed the problem with select all which in turn made a bug in the undo system become visible so I fixed that too.

I do test the fixes to the best of my ability but as everybody knows, bugs are unavoidable, so please keep trying to find more problems if you are inclined to do so and if you want to hear my opinion, the faster they are found the earlier they are fixed..

…election, make sure that the interactive selection is equal to the state selection.
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.

[Bug] Pattern Editor: Selection skips over lines/characters when done immediately after deleting text

2 participants