-
Notifications
You must be signed in to change notification settings - Fork 249
fix(repeatable_move): repeat_last_move always uses count 1 when used in operator-pending (no) mode. #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(repeatable_move): repeat_last_move always uses count 1 when used in operator-pending (no) mode. #861
Conversation
…d in operator-pending (no) mode.
3836331 to
fce6020
Compare
|
Thanks. I rebased it so I can run tests, but if you don't like that I'm in the commit author you can rebase again yourself. This fixes the fFtT cases but maybe not the other functions? Anyway, this kind of bug is infinite like if we fix one we introduce another.. And I usually use I can merge it if you don't mind that it probably still won't work everywhere, but honestly it's more common to count for fFtT commands than to count bigger chunks like function, class etc. thus I didn't even notice it. |
All good. Please keep it as-is. I just want to make sure that it works ;-)
It fixes -- we assume other textobjects (move) already handle operator-pending mode correctly
M.last_move.func(opts, unpack(M.last_move.additional_args))work just fine -- there is no invokation of the I have discovered it when I was doing (something like) |
|
Oh, you're right that it works for others too. This looks good to me. Thank you so much! Would you be so kind to add a test for this? That would be awesome. |
|
Great to hear that! Sure. I have written the test cases for that behavior... Unfortunately these test cases don't pass, but the failures are not related to this fix. The
It might be out-of-scope of this PR. Since the test cases are failing I've pushed them to a separate branch and created this PR: #862. |
|
I see. It must be the In my opinion, even though I use repeatable move very frequently I didn't know about that difference and I find it very unintuitive. Just like sometimes Thus I can consider fixing other test cases later, but for now I'm happy with the current behaviour unless others think otherwise. Can you add a test in this PR of the cases it fixes specifically with count, instead of adding all other quirks that don't pass currently? Thank you! |
35537bd to
674539c
Compare
|
I have fixed the Please take a look. I have also added tests for that. |
| local function repeat_last_move_fFtT(opts) | ||
| local motion = '' | ||
|
|
||
| if opts.is_lower then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to introduce another option, or can it just use if M.last_move.func == 'f' or M.last_move.func == 't' then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored it slightly.
Please take a look.
| motion = opts.forward and ',' or ';' | ||
| end | ||
|
|
||
| local inclusive = (opts.forward and vim.api.nvim_get_mode().mode == 'no') and 'v' or '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment like "this changes operator-pending (no) mode to operator-pending-visual (nov) mode to include last character in the region when going forward. In other words, going forward will include current cursor and found character, and going backward will include the found character but NOT the current cursor."
|
Looks good to me, and it works well, thanks a lot! |
674539c to
78c4f1b
Compare
|
Great to hear that. Thank you for your input! |
| elseif M.last_move.func == 'F' or M.last_move.func == 'T' then | ||
| force_operator_pending_visual_mode() | ||
| vim.cmd([[normal! ]] .. vim.v.count1 .. (opts.forward and ',' or ';')) | ||
| if vim.tbl_contains({ 'f', 'F', 't', 'T' }, M.last_move.func) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use vim.list_contains()
…clusive behavior of the `;` and `,` motions used after fFtT motions as in plain NeoVim
78c4f1b to
a7d6bd7
Compare
|
Thanks a lot for the awesome work! |
I've noticed that after switching to
mainbranch frommasterbranch the;and,motions are not using[count]in operator pending mode. For example:df/and then2d;remove 2 slashes instead of expected 3 slashes (count 2 ind;is ignored).My nvim version:
My bindings
nvim-treesitter-textobjects: