diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-08-29 12:48:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 12:48:51 +0200 |
commit | f05cc672e3b617b4480d8e2d7efc7e00863efc3d (patch) | |
tree | f5635d5e6a2a3fc1716a5d50881bcff3ddde1c20 /src/nvim/cursor.c | |
parent | 253f0ffd8d4784b7fca03f8f6c2455b9ee83ff9b (diff) | |
parent | ea4e9c71ccaf406fe7aa6b47d461cdab2d6c01e9 (diff) | |
download | rneovim-f05cc672e3b617b4480d8e2d7efc7e00863efc3d.tar.gz rneovim-f05cc672e3b617b4480d8e2d7efc7e00863efc3d.tar.bz2 rneovim-f05cc672e3b617b4480d8e2d7efc7e00863efc3d.zip |
Merge pull request #19975 from bfredl/chartabsize
refactor(plines): use a struct for chartabsize state
Diffstat (limited to 'src/nvim/cursor.c')
-rw-r--r-- | src/nvim/cursor.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 14ebc11cbf..ed0488cf76 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -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 |