mirror of
https://github.com/neovim/neovim.git
synced 2025-09-10 21:38:19 +00:00
refactor(plines): use a struct for chartabsize state
This is a refactor extracted from vim-patch 9.0.0067: cannot show virtual text The logic for inline virtual text is going to be different in nvim than text property based text in vim, but this refactor is still useful, as calculation of displayed linesize is going to be stateful in a similar way.
This commit is contained in:
@@ -137,14 +137,18 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
|
||||
}
|
||||
}
|
||||
|
||||
char_u *ptr = line;
|
||||
while (col <= wcol && *ptr != NUL) {
|
||||
chartabsize_T cts;
|
||||
init_chartabsize_arg(&cts, curwin, pos->lnum, 0, line, line);
|
||||
while (cts.cts_vcol <= wcol && *cts.cts_ptr != NUL) {
|
||||
// Count a tab for what it's worth (if list mode not on)
|
||||
csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
|
||||
MB_PTR_ADV(ptr);
|
||||
col += csize;
|
||||
csize = win_lbr_chartabsize(&cts, &head);
|
||||
MB_PTR_ADV(cts.cts_ptr);
|
||||
cts.cts_vcol += csize;
|
||||
}
|
||||
idx = (int)(ptr - line);
|
||||
col = cts.cts_vcol;
|
||||
idx = (int)(cts.cts_ptr - (char *)line);
|
||||
clear_chartabsize_arg(&cts);
|
||||
|
||||
// Handle all the special cases. The virtual_active() check
|
||||
// is needed to ensure that a virtual position off the end of
|
||||
// a line has the correct indexing. The one_more comparison
|
||||
|
Reference in New Issue
Block a user