diff options
author | phanium <91544758+phanen@users.noreply.github.com> | 2025-03-13 09:11:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-13 09:11:08 +0800 |
commit | d832518ec6b4604c27d8ce9c9587a4641f2337fe (patch) | |
tree | 36d550bd7f6dfb35c98335af7c4f753cfd7b7a84 /test/functional/lua/hl_spec.lua | |
parent | b25527d20d9a5ae25f4a5e2d2d487e2eac731b2c (diff) | |
download | rneovim-d832518ec6b4604c27d8ce9c9587a4641f2337fe.tar.gz rneovim-d832518ec6b4604c27d8ce9c9587a4641f2337fe.tar.bz2 rneovim-d832518ec6b4604c27d8ce9c9587a4641f2337fe.zip |
fix(lua): vim.hl.on_yank highlights wrong region with yi' (#32850)
Problem: yi' don't highlight last character since
https://github.com/neovim/neovim/commit/8ce504820af04194a41acbe1f4c61cf12bd5feb5.
Solution: Always use `opts.inclusive=true`, since calculation of `"]`
(`b_op_end`) have taken `inclusive` into account.
Diffstat (limited to 'test/functional/lua/hl_spec.lua')
-rw-r--r-- | test/functional/lua/hl_spec.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/lua/hl_spec.lua b/test/functional/lua/hl_spec.lua index 27629cf214..12be01e0a5 100644 --- a/test/functional/lua/hl_spec.lua +++ b/test/functional/lua/hl_spec.lua @@ -214,4 +214,37 @@ describe('vim.hl.on_yank', function() vim.hl.range(0, ns, 'Search', { 0, 0 }, { 0, 0 }, { timeout = 0 }) end) end) + + it('highlights last character with exclusive motion', function() + local screen = Screen.new(60, 4) + screen:add_extra_attr_ids({ + [100] = { foreground = Screen.colors.Blue, background = Screen.colors.Yellow, bold = true }, + }) + command('autocmd TextYankPost * lua vim.hl.on_yank{timeout=100000}') + api.nvim_buf_set_lines(0, 0, -1, true, { + [[foo(bar) 'baz']], + [[foo(bar) 'baz']], + }) + n.feed('yw') + screen:expect([[ + {2:^foo}(bar) 'baz' | + foo(bar) 'baz' | + {1:~ }| + | + ]]) + n.feed("yi'") + screen:expect([[ + foo(bar) '{2:^baz}' | + foo(bar) 'baz' | + {1:~ }| + | + ]]) + n.feed('yvj') + screen:expect([[ + foo(bar) '{2:^baz'} | + {2:foo(bar) '}baz' | + {1:~ }| + | + ]]) + end) end) |