Skip to content

Conversation

@TheLeoP
Copy link
Member

@TheLeoP TheLeoP commented Jan 28, 2026

Partially fixes #2247

@echasnovski
Copy link
Member

If it is a change in do_between_marks, then I think it is reasonable to also add tests for all operators that use it. Namely, "multiply" and "exchange".

Also, I am a bit hesitant to yet merge this as it doesn't address both problems of #2247.

@TheLeoP
Copy link
Member Author

TheLeoP commented Jan 28, 2026

If it is a change in do_between_marks, then I think it is reasonable to also add tests for all operators that use it. Namely, "multiply" and "exchange".

On it.

Also, I am a bit hesitant to yet merge this as it doesn't address both problems of #2247.

Fair. I'll try to take a look at what may be causing the issue with the trailing newline tomorrow

@TheLeoP
Copy link
Member Author

TheLeoP commented Feb 2, 2026

I changed the commit message to include newlines at the end of textobject because I added a test for a different edge case on MiniOperators.replace that happened only on visual mode and only when replacing a region with a trailing newline. But, the operator still duplicates the trailing newline (it can't delete it because, as explained in #2247 (comment) , custom operators can't see trailing newlines).

We would be accepting that this is a current limitation of Neovim and the behavior is expected.

@echasnovski
Copy link
Member

Could you please move cache-set-unset of 'virtualedit' at least inside H.exchange_do or explore if only moving it inside H.replace_do is enough . Preferably closer to commands when they are actually needed (i.e. not at the top and bottom).

Also, please add the same one-line comment above each 'virtualedit' caching describing why this is needed.

For tests, it looks like the behavior is Visual mode specific. So could you please move them after 'works in Visual mode' cases for each operator and be more general like 'works with newline in region'. For trailing newlines in exchange and multiply having a comment about why it doesn't work (like Doesn't work due to Neovim limitations\nSee https://github.com/neovim/neovim/issues/37664).

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.operators] some operators have issues with newlines at start/end of textobject

2 participants