Patch 8.2.1511

6 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 22, 2020, 3:09:27 PM8/22/20
to vim...@googlegroups.com

Patch 8.2.1511
Problem: Putting a string in Visual block mode ignores multi-byte
characters.
Solution: Adjust the column for Visual block mode. (closes #6767)
Files: src/register.c, src/testdir/test_visual.vim


*** ../vim-8.2.1510/src/register.c 2020-07-10 20:24:04.681880420 +0200
--- src/register.c 2020-08-22 21:08:29.216922366 +0200
***************
*** 1937,1952 ****
--lnum;
new_cursor = curwin->w_cursor;

! // simple case: insert into current line
if (y_type == MCHAR && y_size == 1)
{
! linenr_T end_lnum = 0; // init for gcc

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;
}

do {
--- 1937,1965 ----
--lnum;
new_cursor = curwin->w_cursor;

! // simple case: insert into one line at a time
if (y_type == MCHAR && 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)
+ {
+ pos_T pos;
+
+ // "col" is valid for the first line, in following lines
+ // the virtual column needs to be used. Matters for
+ // multi-byte characters.
+ pos.lnum = lnum;
+ pos.col = col;
+ pos.coladd = 0;
+ getvcol(curwin, &pos, NULL, &vcol, NULL);
+ }
}

do {
***************
*** 1954,1959 ****
--- 1967,1982 ----
if (totlen > 0)
{
oldp = ml_get(lnum);
+ if (lnum > start_lnum)
+ {
+ pos_T pos;
+
+ pos.lnum = lnum;
+ if (getvpos(&pos, vcol) == OK)
+ col = pos.col;
+ else
+ col = MAXCOL;
+ }
if (VIsual_active && col > (int)STRLEN(oldp))
{
lnum++;
*** ../vim-8.2.1510/src/testdir/test_visual.vim 2020-06-20 16:05:29.016185239 +0200
--- src/testdir/test_visual.vim 2020-08-22 20:49:58.352987056 +0200
***************
*** 922,925 ****
--- 922,934 ----
close!
endfunc

+ func Test_visual_put_in_block()
+ new
+ call setline(1, ['xxxx', 'y∞yy', 'zzzz'])
+ normal 1G2yl
+ exe "normal 1G2l\<C-V>jjlp"
+ call assert_equal(['xxxx', 'y∞xx', 'zzxx'], getline(1, 3))
+ bwipe!
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.1510/src/version.c 2020-08-22 19:01:57.612441916 +0200
--- src/version.c 2020-08-22 20:46:23.789811428 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1511,
/**/

--
hundred-and-one symptoms of being an internet addict:
268. You get up in the morning and go online before getting your coffee.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages