comparison src/register.c @ 21923:2626306efe44 v8.2.1511

patch 8.2.1511: putting a string in Visual block mode ignores multi-byte Commit: https://github.com/vim/vim/commit/cd94277f72e29b740635da84bcd872c96e11bf67 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 22 21:08:44 2020 +0200 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 #6767)
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Aug 2020 21:15:03 +0200
parents 136b33ce8216
children 6941d3205be9
comparison
equal deleted inserted replaced
21922:bad21603b8c4 21923:2626306efe44
1935 // Line mode: BACKWARD is the same as FORWARD on the previous line 1935 // Line mode: BACKWARD is the same as FORWARD on the previous line
1936 else if (dir == BACKWARD) 1936 else if (dir == BACKWARD)
1937 --lnum; 1937 --lnum;
1938 new_cursor = curwin->w_cursor; 1938 new_cursor = curwin->w_cursor;
1939 1939
1940 // simple case: insert into current line 1940 // simple case: insert into one line at a time
1941 if (y_type == MCHAR && y_size == 1) 1941 if (y_type == MCHAR && y_size == 1)
1942 { 1942 {
1943 linenr_T end_lnum = 0; // init for gcc 1943 linenr_T end_lnum = 0; // init for gcc
1944 linenr_T start_lnum = lnum;
1944 1945
1945 if (VIsual_active) 1946 if (VIsual_active)
1946 { 1947 {
1947 end_lnum = curbuf->b_visual.vi_end.lnum; 1948 end_lnum = curbuf->b_visual.vi_end.lnum;
1948 if (end_lnum < curbuf->b_visual.vi_start.lnum) 1949 if (end_lnum < curbuf->b_visual.vi_start.lnum)
1949 end_lnum = curbuf->b_visual.vi_start.lnum; 1950 end_lnum = curbuf->b_visual.vi_start.lnum;
1951 if (end_lnum > start_lnum)
1952 {
1953 pos_T pos;
1954
1955 // "col" is valid for the first line, in following lines
1956 // the virtual column needs to be used. Matters for
1957 // multi-byte characters.
1958 pos.lnum = lnum;
1959 pos.col = col;
1960 pos.coladd = 0;
1961 getvcol(curwin, &pos, NULL, &vcol, NULL);
1962 }
1950 } 1963 }
1951 1964
1952 do { 1965 do {
1953 totlen = count * yanklen; 1966 totlen = count * yanklen;
1954 if (totlen > 0) 1967 if (totlen > 0)
1955 { 1968 {
1956 oldp = ml_get(lnum); 1969 oldp = ml_get(lnum);
1970 if (lnum > start_lnum)
1971 {
1972 pos_T pos;
1973
1974 pos.lnum = lnum;
1975 if (getvpos(&pos, vcol) == OK)
1976 col = pos.col;
1977 else
1978 col = MAXCOL;
1979 }
1957 if (VIsual_active && col > (int)STRLEN(oldp)) 1980 if (VIsual_active && col > (int)STRLEN(oldp))
1958 { 1981 {
1959 lnum++; 1982 lnum++;
1960 continue; 1983 continue;
1961 } 1984 }