vim-patch:8.2.1511: putting a string in Visual block mode ignores multi-byte

Problem:    Putting a string in Visual block mode ignores multi-byte
            characters.
Solution:   Adjust the column for Visual block mode. (closes vim/vim#6767)
cd94277f72
This commit is contained in:
Jan Edmund Lazo
2020-08-22 17:00:13 -04:00
parent 091fc72a92
commit 246c510b60
2 changed files with 34 additions and 1 deletions

View File

@@ -3238,21 +3238,43 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
--lnum;
new_cursor = curwin->w_cursor;
// simple case: insert into current line
// simple case: insert into one line at a time
if (y_type == kMTCharWise && y_size == 1) {
linenr_T end_lnum = 0; // init for gcc
linenr_T start_lnum = lnum;
if (VIsual_active) {
end_lnum = curbuf->b_visual.vi_end.lnum;
if (end_lnum < curbuf->b_visual.vi_start.lnum) {
end_lnum = curbuf->b_visual.vi_start.lnum;
}
if (end_lnum > start_lnum) {
// "col" is valid for the first line, in following lines
// the virtual column needs to be used. Matters for
// multi-byte characters.
pos_T pos = {
.lnum = lnum,
.col = col,
.coladd = 0,
};
getvcol(curwin, &pos, NULL, &vcol, NULL);
}
}
do {
totlen = (size_t)(count * yanklen);
if (totlen > 0) {
oldp = ml_get(lnum);
if (lnum > start_lnum) {
pos_T pos = {
.lnum = lnum,
};
if (getvpos(&pos, vcol) == OK) {
col = pos.col;
} else {
col = MAXCOL;
}
}
if (VIsual_active && col > (int)STRLEN(oldp)) {
lnum++;
continue;