diff options
Diffstat (limited to 'src/register.c')
-rw-r--r-- | src/register.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/register.c b/src/register.c index 30e2001da4..9a5e11b9ce 100644 --- a/src/register.c +++ b/src/register.c @@ -1820,8 +1820,9 @@ do_put( bd.textcol = 0; for (i = 0; i < y_size; ++i) { - int spaces = 0; - char shortline; + int spaces = 0; + char shortline; + chartabsize_T cts; bd.startspaces = 0; bd.endspaces = 0; @@ -1839,13 +1840,19 @@ do_put( // get the old line and advance to the position to insert at oldp = ml_get_curline(); oldlen = (int)STRLEN(oldp); - for (ptr = oldp; vcol < col && *ptr; ) + init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0, + oldp, oldp); + + while (cts.cts_vcol < col && *cts.cts_ptr != NUL) { // Count a tab for what it's worth (if list mode not on) - incr = lbr_chartabsize_adv(oldp, &ptr, vcol); - vcol += incr; + incr = lbr_chartabsize_adv(&cts); + cts.cts_vcol += incr; } + vcol = cts.cts_vcol; + ptr = cts.cts_ptr; bd.textcol = (colnr_T)(ptr - oldp); + clear_chartabsize_arg(&cts); shortline = (vcol < col) || (vcol == col && !*ptr) ; @@ -1876,8 +1883,15 @@ do_put( // calculate number of spaces required to fill right side of // block spaces = y_width + 1; + init_chartabsize_arg(&cts, curwin, 0, 0, + y_array[i], y_array[i]); for (j = 0; j < yanklen; j++) - spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); + { + spaces -= lbr_chartabsize(&cts); + ++cts.cts_ptr; + cts.cts_vcol = 0; + } + clear_chartabsize_arg(&cts); if (spaces < 0) spaces = 0; } |