Merge pull request #14502 from chentau/extmark_paste

Splice extmarks on every line for block visual paste
This commit is contained in:
Björn Linse 2021-05-07 10:52:36 +02:00 committed by GitHub
commit 8c9f0f1da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 6 deletions

View File

@ -3334,6 +3334,9 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
changed_cline_bef_curs(); changed_cline_bef_curs();
curwin->w_cursor.col += (colnr_T)(totlen - 1); curwin->w_cursor.col += (colnr_T)(totlen - 1);
} }
changed_bytes(lnum, col);
extmark_splice_cols(curbuf, (int)lnum-1, col,
0, (int)totlen, kExtmarkUndo);
} }
if (VIsual_active) { if (VIsual_active) {
lnum++; lnum++;
@ -3345,12 +3348,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
} }
curbuf->b_op_end = curwin->w_cursor; curbuf->b_op_end = curwin->w_cursor;
/* For "CTRL-O p" in Insert mode, put cursor after last char */ // For "CTRL-O p" in Insert mode, put cursor after last char
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) {
++curwin->w_cursor.col; curwin->w_cursor.col++;
changed_bytes(lnum, col); }
extmark_splice_cols(curbuf, (int)lnum-1, col,
0, (int)totlen, kExtmarkUndo);
} else { } else {
// Insert at least one line. When y_type is kMTCharWise, break the first // Insert at least one line. When y_type is kMTCharWise, break the first
// line in two. // line in two.

View File

@ -936,6 +936,28 @@ describe('lua: nvim_buf_attach on_bytes', function()
} }
end) end)
it("block visual paste", function()
local check_events = setup_eventcheck(verify, {"AAA",
"BBB",
"CCC",
"DDD",
"EEE",
"FFF"})
funcs.setreg("a", "___")
feed([[gg0l<c-v>3jl"ap]])
check_events {
{ "test1", "bytes", 1, 3, 0, 1, 1, 0, 2, 2, 0, 0, 0 };
{ "test1", "bytes", 1, 3, 1, 1, 3, 0, 2, 2, 0, 0, 0 };
{ "test1", "bytes", 1, 3, 2, 1, 5, 0, 2, 2, 0, 0, 0 };
{ "test1", "bytes", 1, 3, 3, 1, 7, 0, 2, 2, 0, 0, 0 };
{ "test1", "bytes", 1, 5, 0, 1, 1, 0, 0, 0, 0, 3, 3 };
{ "test1", "bytes", 1, 6, 1, 1, 6, 0, 0, 0, 0, 3, 3 };
{ "test1", "bytes", 1, 7, 2, 1, 11, 0, 0, 0, 0, 3, 3 };
{ "test1", "bytes", 1, 8, 3, 1, 16, 0, 0, 0, 0, 3, 3 };
}
end)
teardown(function() teardown(function()
os.remove "Xtest-reload" os.remove "Xtest-reload"
os.remove "Xtest-undofile" os.remove "Xtest-undofile"