Skip to content

feat(jump)!: make dot-repeat jumping separate from regular jumping#2284

Merged
echasnovski merged 1 commit intonvim-mini:backlogfrom
abeldekat:fix_jump_dot_repeat
Feb 28, 2026
Merged

feat(jump)!: make dot-repeat jumping separate from regular jumping#2284
echasnovski merged 1 commit intonvim-mini:backlogfrom
abeldekat:fix_jump_dot_repeat

Conversation

@abeldekat
Copy link
Member

Resolve #2054

@abeldekat
Copy link
Member Author

I am not sure if the extra tests in 'works after jump in Operator-pending mode' are actually needed, as the behavior of ; has not been changed.
It still reuses the jump from dot-repeat. The motion is only different because dot-repeat itself has been changed.

Copy link
Member

@echasnovski echasnovski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

The idea and tests overall look good! The large amount of comments is only there because it is possible to focus on little things :)

@echasnovski echasnovski changed the title feat(jump): ensure dot-repeat jumping only reuses jumps from changes feat(jump): ensure dot-repeat jumping does not affect regular jumping Feb 26, 2026
@echasnovski
Copy link
Member

Also, please adjust commit message to fit the new PR title. Dot-repeat is technically not only about changes (yank can be dot-repeated under some circumstances, for example).

@abeldekat
Copy link
Member Author

Also, please adjust commit message to fit the new PR title. Dot-repeat is technically not only about changes (yank can be dot-repeated under some circumstances, for example).

Indeed. However, as I understand this PR, the title should be:

"ensure dot-repeat jumping is not affected by regular jumping"

@echasnovski echasnovski changed the title feat(jump): ensure dot-repeat jumping does not affect regular jumping feat(jump)!: make dot-repeat jumping separate from regular jumping Feb 26, 2026
@echasnovski
Copy link
Member

Indeed. However, as I understand this PR, the title should be:

"ensure dot-repeat jumping is not affected by regular jumping"

It goes both ways. And it is also a breaking change. So updated to be "make dot-repeat jumping separate from regular jumping".

@abeldekat abeldekat force-pushed the fix_jump_dot_repeat branch 2 times, most recently from 968a78c to ab80866 Compare February 27, 2026 07:16

-- If dot-repeating the state needs to be restored after the jump
local state_snapshot
if MiniJump.is_expr and not (MiniJump.state.mode == 'no' and vim.fn.mode(1) == 'nov') then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why extra check for the forced charwise mode is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the operation is invoked the first time in make_expr_jump we are not dot-repeating and the state should not be restored. Otherwise, after the jump, state.mode is still 'no', as it was in make_expr_jump.

FAIL in tests/test_jump.lua | state | updates `mode`:
  Failed expectation for equality
  Cause: different string length
  Left:  "no"
  Right: "nov"
  Traceback:
    tests/test_jump.lua:185

Copy link
Member

@echasnovski echasnovski Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Still, the extra check doesn't feel like a good solution to any problem it is meant to solve.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I misread the question. Indeed, this is an example of doing too much...
Changed into: local needs_restore = MiniJump._is_expr and MiniJump.state.mode ~= 'no'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is to differentiate initial application of expression mapping from its dot-repeat.

I still don't think that relying on checking the mode is a robust solution. Couldn't immediately find the failing example, though.

There is a more direct approach to distinguish first and second+ calls of expression mapping output: set another flag (like _expr_map_init) in the expression mapping RHS. Then the dot-repeat is MiniJump._expr_map and not MiniJump._expr_map_init.

As it already feels like a nit picking, I'll merge into a temporary branch and adjust myself.

Copy link
Member Author

@abeldekat abeldekat Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes...)

I did think about that extra flag. That's also an extra something to reset though... Anyways, no nitpicking. Your feedback is very valuable as always and I look forward to seeing the final version

@abeldekat
Copy link
Member Author

I pushed the new commit

@abeldekat
Copy link
Member Author

Strange, some of my review comments end up as 'pending'.

About the question regarding forced charwise mode:

Why extra check for the forced charwise mode is needed?

if MiniJump.is_expr and not (MiniJump.state.mode == 'no' and vim.fn.mode(1) == 'nov') then

Apologies, I misread the question. Indeed, this is an example of doing too much...
Changed into:

local needs_restore = MiniJump._is_expr and MiniJump.state.mode ~= 'no'

@echasnovski echasnovski changed the base branch from main to backlog February 28, 2026 16:24
@echasnovski echasnovski merged commit 1858dea into nvim-mini:backlog Feb 28, 2026
10 of 12 checks passed
@echasnovski
Copy link
Member

Thanks again for the PR! I've merged into a temporary branch to polish a bit and then merge into main.

@echasnovski
Copy link
Member

The work from this PR should now be part of the latest main. Thanks again for the PR!

Couple of notes:

  • After checking the PR locally, I noticed that this comment was not really addressed. It went unnoticed primarily because there was no dedicated test added for this.

    The reason for this was that created expression hard coded the initial target. So doing something like fe -> d; (hard coded e as target) -> fx -> . (still used e as target although it should use x, as in nvim --clean). Using nil in case of repeat_jump (i.e. ;) solved the issue.

  • Adjusted some tests to be more to the point.

  • Added small note in documentation to show that the dot-repeat behavior is intentional (i.e. "as in clean Neovim").

@abeldekat abeldekat deleted the fix_jump_dot_repeat branch February 28, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mini.jump] Breaks dot-repeat when jumping between repeats

2 participants