Hi Christian! Sorry for the late reply,
On Wednesday, August 5, 2015 at 7:37:51 PM UTC+1, Christian Brabandt wrote: > > Form everything I've read about the expected behaviour for restoring the > > cursor positioning (eg: > > http://vim.wikia.com/wiki/Restore_the_cursor_position_after_undoing_text_change_made_by_a_script), > > the cursor should be restored "closest to where the first change is made". > > > > However, the inconsistency I found is that two almost identical bits of > > vimscript make the editor behave in different ways. > > > > # Test 1 > > > > Imagine I have a buffer with two lines. I do `:normal Go` to add a 3rd line > > into that buffer, then undo it. The closest place to where the first (and > > in this case, the only) change is made is line 2. Thus, the cursor should > > be restored to line 2. > > > > Now, let's complicate things a little. I have the same buffer with two > > lines. I do `:normal Go` to add a 3rd line. But this time, instead of > > `undo`, I do `:undojoin` and then run a substitute command (in my test I > > use `:keepjumps %s/aaaa/zzzz/`). Only then do I do `:undo`. > > > > As far as positioning of the cursor goes, the above two examples should be > > absolutely identical. This is because we've `:undojoined` our substitution > > change onto the back of an existing change, which was the addition of the > > 3rd line. Thus, the closest place to where the *first* change is made is > > still line 2, which is where the cursor should be positioned after the > > `:undo`. > > > > This is exactly how my first test behaves, the one marked with [OK]. > > > > # Test 2 > > > > My second test, marked with [ERR], displays a different set of behaviour. > > It demonstrates that under certain conditions, "closest to where the first > > change is made" rule for the cursor positioning is disregarded and instead > > the cursor is restored nearest to the first substitution made by the > > `:s///` command. This appears to be inconsistent with how the cursor should > > be positioned. > > > > Would anyone be willing to patch this? > > Well, I can see that this might be a problem, but I currently don't > understand the code, that set's the cursor position and therefore am not > sure, how to fix the problem. Not a problem at all. As I said before, I don't understand the code enough either. But I think we've established two very important things: 1. We confirmed that described behaviour is a problem 2. We confirmed that the problem lies within VIM I'm hoping that this might be enough for someone who is a bit more used to VIM's codebase to have a look at this issue and propose a solution… Thanks for all the help Christian, Dmytro -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
