vim-patch:9.0.0178: cursor position wrong with virtual text before Tab

Problem:    Cursor position wrong with virtual text before Tab.
Solution:   Use the byte length, not the cell with, to compare the column.
            Correct tab size after text prop. (closes vim/vim#10866)

e428fa04a7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
Ibby
2023-03-26 16:09:09 +11:00
committed by bfredl
parent 43c2eaada2
commit dee3af2122
3 changed files with 116 additions and 4 deletions

View File

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