Skip to content

Commit

Permalink
fix(bufupdates): send correct updates for visual paste
Browse files Browse the repository at this point in the history
One step further towards stable tree-sitter.

Co-authored-by: Björn Linse <[email protected]>
  • Loading branch information
vigoux and bfredl committed Aug 25, 2021
1 parent 5d63354 commit 1423146
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/nvim/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3444,8 +3444,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
(int)y_size-1, lastsize, totsize,
kExtmarkUndo);
} else if (y_type == kMTLineWise && flags & PUT_LINE_SPLIT) {
extmark_splice(curbuf, (int)new_cursor.lnum-1, col, 0, 0, 0,
(int)y_size+1, 0, totsize+1, kExtmarkUndo);
// Account for last pasted NL + last NL
extmark_splice(curbuf, (int)new_cursor.lnum-1, col + 1, 0, 0, 0,
(int)y_size+1, 0, totsize+2, kExtmarkUndo);
}
}

Expand Down
16 changes: 16 additions & 0 deletions test/functional/lua/buffer_updates_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,22 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)

it("visual paste", function()
local check_events= setup_eventcheck(verify, { "aaa {", "b", "}" })
-- Setting up
feed[[jdd]]
check_events {
{ "test1", "bytes", 1, 3, 1, 0, 6, 1, 0, 2, 0, 0, 0 };
}

-- Actually testing
feed[[v%p]]
check_events {
{ "test1", "bytes", 1, 8, 0, 4, 4, 1, 1, 3, 0, 0, 0 };
{ "test1", "bytes", 1, 8, 0, 4, 4, 0, 0, 0, 2, 0, 3 };
}
end)

it("nvim_buf_set_lines", function()
local check_events = setup_eventcheck(verify, {"AAA", "BBB"})

Expand Down

0 comments on commit 1423146

Please sign in to comment.