diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-09-27 11:40:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-27 11:40:30 -0400 |
| commit | fc3f0041fbe01c96f38224d65d27664b22b5ef78 (patch) | |
| tree | affdee09d7616e9af4658a8afe3c090b718d9ca4 /runtime/lua/vim/treesitter/_select.lua | |
| parent | c216c557fd76c762aa11486ed78e5897a96e6efc (diff) | |
| download | rneovim-fc3f0041fbe01c96f38224d65d27664b22b5ef78.tar.gz rneovim-fc3f0041fbe01c96f38224d65d27664b22b5ef78.tar.bz2 rneovim-fc3f0041fbe01c96f38224d65d27664b22b5ef78.zip | |
fix(editor)!: operator target/cgn modifies Visual marks #42119
Problem:
An operator on a target that creates a Visual selection (`cgn`,
`d<C-v>j`, an omap text object like `:<C-U>normal! viw`) sets `'< '>`,
`gv` and `visualmode()` to the operator target.
This causes at least the following problems:
- clobbers the user's previous `'< '>` (annoying and usually unwanted)
- E.g. after a custom textobj, `:help text-object-define`.
- "cgn" with a `\%V` pattern can't be dot-repeated (".")
Solution:
Don't save the Visual area if the operator target created it (operator
was pending).
Also fix `an`/`in` with `'selection'=exclusive` starting from an empty
range.
Diffstat (limited to 'runtime/lua/vim/treesitter/_select.lua')
| -rw-r--r-- | runtime/lua/vim/treesitter/_select.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/_select.lua b/runtime/lua/vim/treesitter/_select.lua index afdd1a7612..6708e6292f 100644 --- a/runtime/lua/vim/treesitter/_select.lua +++ b/runtime/lua/vim/treesitter/_select.lua @@ -356,7 +356,8 @@ local function get_selection() pos1, pos2 = pos2, pos1 end - if vim.o.selection == 'exclusive' then + -- selection=exclusive excludes end char, except for empty selection (op-pending, or a new "v"). + if vim.o.selection == 'exclusive' and (pos1[2] ~= pos2[2] or pos1[3] ~= pos2[3]) then pos2[3] = pos2[3] - 1 end |