diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/charset.c | 8 | ||||
-rw-r--r-- | src/nvim/plines.c | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 3b48392d49..24267ebd50 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1084,10 +1084,6 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en } if (cursor != NULL) { - if ((State & MODE_INSERT) == 0 && !on_NUL) { - // cursor is after inserted text, unless on the NUL - vcol += cts.cts_cur_text_width; - } if ((*ptr == TAB) && (State & MODE_NORMAL) && !wp->w_p_list @@ -1096,6 +1092,10 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en // cursor at end *cursor = vcol + incr - 1; } else { + if ((State & MODE_INSERT) == 0 && !on_NUL) { + // cursor is after inserted text, unless on the NUL + vcol += cts.cts_cur_text_width; + } // cursor at start *cursor = vcol + head; } diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 59c45d3615..2df9c23902 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -411,6 +411,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) // First get normal size, without 'linebreak' or virtual text int size = win_chartabsize(wp, s, vcol); if (cts->cts_has_virt_text) { + int tab_size = size; int charlen = *s == NUL ? 1 : utf_ptr2len(s); int col = (int)(s - line); while (true) { @@ -425,6 +426,12 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) if (decor.virt_text_pos == kVTInline) { cts->cts_cur_text_width += decor.virt_text_width; size += decor.virt_text_width; + if (*s == TAB) { + // tab size changes because of the inserted text + size -= tab_size; + tab_size = win_chartabsize(wp, s, vcol + size); + size += tab_size; + } } } } |