diff options
Diffstat (limited to 'src/nvim/charset.c')
-rw-r--r-- | src/nvim/charset.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index a02d2a812d..4e8bb3b0d7 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -30,7 +30,7 @@ #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/path.h" - +#include "nvim/cursor.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "charset.c.generated.h" @@ -1344,7 +1344,11 @@ colnr_T getvcol_nolist(pos_T *posp) colnr_T vcol; curwin->w_p_list = false; - getvcol(curwin, posp, NULL, &vcol, NULL); + if (posp->coladd) { + getvvcol(curwin, posp, NULL, &vcol, NULL); + } else { + getvcol(curwin, posp, NULL, &vcol, NULL); + } curwin->w_p_list = list_save; return vcol; } @@ -1375,7 +1379,7 @@ void getvvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, ptr = ml_get_buf(wp->w_buffer, pos->lnum, false); if (pos->col < (colnr_T)STRLEN(ptr)) { - int c = (*mb_ptr2char)(ptr + pos->col); + int c = utf_ptr2char(ptr + pos->col); if ((c != TAB) && vim_isprintc(c)) { endadd = (colnr_T)(char2cells(c) - 1); if (coladd > endadd) { @@ -1461,6 +1465,18 @@ char_u *skipwhite(const char_u *q) return (char_u *)p; } +// getwhitecols: return the number of whitespace +// columns (bytes) at the start of a given line +intptr_t getwhitecols_curline(void) +{ + return getwhitecols(get_cursor_line_ptr()); +} + +intptr_t getwhitecols(const char_u *p) +{ + return skipwhite(p) - p; +} + /// Skip over digits /// /// @param[in] q String to skip digits in. |