aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorAu. <acehinnnqru@gmail.com>2025-03-24 07:10:42 +0800
committerGitHub <noreply@github.com>2025-03-23 16:10:42 -0700
commit9516997eb0ad20146ddddb48ba48c905d512998c (patch)
treeb16e07df4e8eb8b2e2fd2b847592afab272d6621 /test/functional/api/vim_spec.lua
parent2eddd6f7c07980e6e1734a490c3f3d7a598436e6 (diff)
downloadrneovim-9516997eb0ad20146ddddb48ba48c905d512998c.tar.gz
rneovim-9516997eb0ad20146ddddb48ba48c905d512998c.tar.bz2
rneovim-9516997eb0ad20146ddddb48ba48c905d512998c.zip
fix(paste): wrong '[ mark after pasting a big string (streamed chunks) #33025
Problem Pasting a big string ("streamed paste" with multiple chunks) sets the '[ mark to the edit from the last chunk, instead of the start of the paste. Solution: Set the '[ mark where the paste started, not where the last chunk was inserted. Note: `startpos == nil` is not equal to `phase == 1` because there may be some empty chunks pasted which won't arrive here (returned at code before).
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 18e6dbd9b6..249ba611f0 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -853,6 +853,39 @@ describe('API', function()
feed('u') -- Undo.
expect(expected1)
end)
+ it("stream: multiple chunks sets correct '[ mark", function()
+ -- Pastes single chunk
+ api.nvim_paste('aaaaaa\n', true, -1)
+ eq({ 0, 1, 1, 0 }, fn.getpos("'["))
+ -- Pastes an empty chunk
+ api.nvim_paste('', true, -1)
+ eq({ 0, 2, 1, 0 }, fn.getpos("'["))
+ -- Pastes some chunks on empty line
+ api.nvim_paste('1/chunk 1 (start)\n', true, 1)
+ eq({ 0, 2, 1, 0 }, fn.getpos("'["))
+ api.nvim_paste('1/chunk 2\n', true, 2)
+ eq({ 0, 2, 1, 0 }, fn.getpos("'["))
+ api.nvim_paste('1/chunk 3 (end)\n', true, 3)
+ eq({ 0, 2, 1, 0 }, fn.getpos("'["))
+ -- Pastes some chunks on non-empty line
+ api.nvim_paste('aaaaaa', true, -1)
+ eq({ 0, 5, 1, 0 }, fn.getpos("'["))
+ api.nvim_paste('bbbbbb', true, 1)
+ eq({ 0, 5, 7, 0 }, fn.getpos("'["))
+ api.nvim_paste('cccccc', true, 2)
+ eq({ 0, 5, 7, 0 }, fn.getpos("'["))
+ api.nvim_paste('dddddd\n', true, 3)
+ eq({ 0, 5, 7, 0 }, fn.getpos("'["))
+ -- Pastes some empty chunks between non-empty chunks
+ api.nvim_paste('', true, 1)
+ eq({ 0, 5, 7, 0 }, fn.getpos("'["))
+ api.nvim_paste('a', true, 2)
+ eq({ 0, 6, 1, 0 }, fn.getpos("'["))
+ api.nvim_paste('', true, 2)
+ eq({ 0, 6, 1, 0 }, fn.getpos("'["))
+ api.nvim_paste('a', true, 3)
+ eq({ 0, 6, 1, 0 }, fn.getpos("'["))
+ end)
it('stream: Insert mode', function()
-- If nvim_paste() calls :undojoin without making any changes, this makes it an error.
feed('afoo<Esc>u')