echasnovski / mini.nvim

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

`virtualedit=all` and `gr` operator #1201

Closed aidancz closed 1 week ago

aidancz commented 1 week ago

Contributing guidelines

Module(s)

mini.operators

Description

with virtualedit=all, the behaviour of replacing the last word with register is wrong

Neovim version

0.10.1

Steps to reproduce

  1. prepare file:
vanilla emacs
  1. set virtualedit=all

  2. press yiwwgriw

Expected behavior

the text becomes

vanilla vanilla

Actual behavior

the text becomes

vanilla vanilla

(there are 2 spaces)

echasnovski commented 1 week ago

Thanks for the issue!

Can reproduce this. I vaguely remember that I tried to support all 'virtualedit' values (as there are tests for virtualedit=block and block mode) but maybe opted out to not support some edge cases as it would require some non-trivial code. I'll take a look.

echasnovski commented 1 week ago

This now should be fixed on latest main. And the fix proved to be half a line long with a pretty intuitive explanation (whether cursor position is a charwise edge should always be false in case of virtualedit=all, as there is no "edge" in this case).

Plus there are now tests for all 'virtualedit' values in most common issue-inducing scenarios.

Thanks again for finding it!