summaryrefslogtreecommitdiffstats
path: root/src/misc2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/misc2.c b/src/misc2.c
index e03ca4936d..c5149ff21b 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -128,7 +128,6 @@ coladvance2(
{
colnr_T wcol = wcol_arg;
int idx;
- char_u *ptr;
char_u *line;
colnr_T col = 0;
int csize = 0;
@@ -158,6 +157,7 @@ coladvance2(
else
{
int width = curwin->w_width - win_col_off(curwin);
+ chartabsize_T cts;
if (finetune
&& curwin->w_p_wrap
@@ -180,19 +180,22 @@ coladvance2(
}
}
- ptr = line;
- while (col <= wcol && *ptr != NUL)
+ 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)
#ifdef FEAT_LINEBREAK
- csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
- MB_PTR_ADV(ptr);
+ csize = win_lbr_chartabsize(&cts, &head);
+ MB_PTR_ADV(cts.cts_ptr);
#else
- csize = lbr_chartabsize_adv(line, &ptr, col);
+ csize = lbr_chartabsize_adv(&cts);
#endif
- col += csize;
+ cts.cts_vcol += csize;
}
- idx = (int)(ptr - line);
+ col = cts.cts_vcol;
+ idx = (int)(cts.cts_ptr - 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