On Thu, November 14, 2013 00:23, Christian Wellenbrock wrote: > On Monday, August 12, 2013 9:22:21 PM UTC+2, Christian Brabandt wrote: >> On Do, 08 Aug 2013, Dimitar DIMITROV wrote: >> >> >> >> > As per the subject :) >> >> >> >> Can you check, whether the attached patch fixes it for you? > > I'd like to bring this up again. I was surprised that `gUgn` wasn't > repeatable and took a dive into the code. I solved it in a different way > and found this topic while I wanted to submit my patch. > > I discovered that the `gn` command used the `redobuff` in a differend way > [1] than most commands. The command `dgn` would write `gnd` to the > `redobuff` instead of the more natuaral `dgn`. To make redo work, there > was some special code [2] needed to read the `d` after `gn` to issue the > deletion. > > This breaks when using two character operators. The command `gUgn` writes > `gngU` to the stuffbuff. The `.` command would now only get one extra char > after `gn`, leading to the repeated command `gng`, which does nothing. > > Getting another extra char in that case would probably work, but instead I > tried to reverse the `redobuff`. Instead of `gngU` from [1] I wrote `gUgn` > to the `stuffbuff` and suddenly everything worked. When repeated, the `gU` > command pends, `gn` selects the next match and the pending operator makes > it uppercase. > > After that I could remove the special behavior mentioned in [2]. > > Here is a small test case to demonstrate the difference. The following vim > invocation inserts "vim vim", searches for "vim", uppercases the first > match, but fails to uppercase the second match upon repetition. Result: > "VIM vim" > > ./vim -c ':exe "norm 2Ivim \<Esc>x#gUgn."' > > The same invocation with the attached `gugn_repeat.patch` applied, yields > the expected "VIM VIM". > > > Bonus: In the `gn` implementation `current_search` there is an early > return [3] that doesn't restore the 'wrapscan' option. This happens when > the search pattern cannot be found.
Good catch. Thanks. > > So after you deleted all occurences of a pattern by repeating `dgn`, the > 'nowrapscan' option will remain set. I fixed this by restoring 'wrapscan' > before returning. > > Test case: Start vim with this invocation and execute the ex command `:set > ws?` to verify that 'nowrapscan' is set. > > ./vim -c ':let @/="a"|norm "dgn"' > > The same invocation with the attached `gn_wrapscan.patch` applied, still > has 'wrapscan' set as expected. > > > @ Christian Brabandt: Was there any intention in the reversed `stuffbuff` > order that I might have missed? Not that I remember. I think, this is ok, since this removes to special case the 'gn' operator. Thanks, Christian -- -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.