diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2021-08-24 17:57:57 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-08-25 15:11:39 +0200 |
commit | 14231463a49d445d5cb889897b2f5cc4b99fbe06 (patch) | |
tree | 8d079f19bba1b05bc3a8d89bc50df864da512557 | |
parent | 5d633546bf5990d03e4b4dc1df213f88316115e6 (diff) | |
download | rneovim-14231463a49d445d5cb889897b2f5cc4b99fbe06.tar.gz rneovim-14231463a49d445d5cb889897b2f5cc4b99fbe06.tar.bz2 rneovim-14231463a49d445d5cb889897b2f5cc4b99fbe06.zip |
fix(bufupdates): send correct updates for visual paste
One step further towards stable tree-sitter.
Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
-rw-r--r-- | src/nvim/ops.c | 5 | ||||
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 178b454e4e..a06db4a551 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -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); } } diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index a5b613f0b2..073927bf22 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -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"}) |