Repository navigation
Fix cursor relocation when inside removed text - #3977
Conversation
|
Similar bugs exist for |
|
Thanks for the review. You are correct that However, the primary goal of this PR was to fix the cursor desync issues causing annoying cursor jumps. Fixing |
|
That's fair. I pointed it out because that's the issue I first assumed this PR was fixing, and I was surprised to see no change in behavior when I went to test it. |
|
No worries, that makes sense. Would you be able to review this PR? I was hoping to get this merged soon, as this fix is a prerequisite for some more bug fixes I have already prepared. |
|
I had no time to do the review yet, but absolutely great to see an official test for this! 👍 |
|
Apologies for long delayed review. The fix looks good to me, thanks. Please just split the 2nd commit to separate the actual fix from the tests, as I asked above. I haven't reviewed the tests yet. |
|
BTW a simple lua function for testing the fix (can be bound to a key via function removeAround(bp)
bp.Buf:Remove(bp.Cursor.Loc:Move(-2, bp.Buf), bp.Cursor.Loc:Move(2, bp.Buf))
end |
8dcf9a8 to
a5baf1c
Compare
Previously, if a cursor was positioned strictly inside a range of text being removed (start < cursor < end), the event handler failed to update its position. This resulted in the cursor retaining its old X/Y coordinates, effectively "jumping" forward into subsequent text. The fix ensures that any cursor inside the removed region is clamped to the start of the deletion.
a5baf1c to
5348393
Compare
5348393 to
7d5e0df
Compare
- Basic insert/remove/replace operations - Trailing whitespace updates - Multiple cursors inside, before and after removed regions - Cursors spanning across removal boundaries - Multiline replacements
7d5e0df to
d26470f
Compare
|
Thank you for the thorough review! 😄 |
This PR fixes a bug in the buffer event handler where cursors positioned strictly inside a removed text range (start < cursor < end) were not correctly updated.
Previously, the
DoTextEventlogic forTextEventRemovehandled cursors after the removed range and cursors at the end of the range, but fell through for cursors residing inside the range. This caused such cursors to retain their original (x, y) coordinates. Since the text before them was deleted, retaining the old coordinates meant the cursor effectively "jumped" forward relative to the content.Reproduction:
Without the Lua plugin system, it is difficult to trigger the bug, but it can be easily reproduced with the following code: