echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.45k stars 172 forks source link

mini.operators leaves behind marks when undoing actions #941

Open PowerUser64 opened 1 month ago

PowerUser64 commented 1 month ago

Contributing guidelines

Module(s)

mini.operators

Description

mini.operators' exchange function leaves behind marks when undoing.

Neovim version

0.10.0

Steps to reproduce

mini.operators bug.webm

(good so far)

oh no, we now have two marks on this line (x and y)!

Note that here, marks.nvim is used to display (and later delete) the marks that the exchange operation leaves behind, but it is reproducible without it.

Expected behavior

mini.operators should leave marks the same as they were before the edit was performed, and not re-place them when an edit is undone.

Actual behavior

mini.operators currently causes the x and y marks to be replaced when undoing a change done by the exchange operation.

echasnovski commented 1 month ago

Thanks for the issue!

'mini.operators' does the best I could find to not have any side effects. It uses marks x and y as temporary marks for a more proper yanking of selected pair of text regions. They are restored to what they were prior to exchange.

Expected behavior

mini.operators should leave marks the same as they were before the edit was performed, and not re-place them when an edit is undone.

Actual behavior

mini.operators currently causes the x and y marks to be replaced when undoing a change done by the exchange operation.

So it does leave them as they were before the edit. Undoing the edit is not done by 'mini.operators' itself, so it has little control over it.

I'll take a look if it is feasible for "exchange" to do its edit in a way that works with this "undo" use case, but I'd say that this both 1) doesn't look like a huge issue; and 2) may be very convoluted to actually achieve.