diff options
-rw-r--r-- | src/nvim/change.c | 4 | ||||
-rw-r--r-- | src/nvim/charset.c | 9 | ||||
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/mouse.c | 10 |
6 files changed, 13 insertions, 18 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index 49e403425a..6a20b208df 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -593,9 +593,9 @@ void ins_char_bytes(char_u *buf, size_t charlen) // cells. May result in adding spaces to fill a gap. colnr_T vcol; getvcol(curwin, &curwin->w_cursor, NULL, &vcol, NULL); - colnr_T new_vcol = vcol + chartabsize(buf, vcol); + colnr_T new_vcol = vcol + win_chartabsize(curwin, buf, vcol); while (oldp[col + oldlen] != NUL && vcol < new_vcol) { - vcol += chartabsize(oldp + col + oldlen, vcol); + vcol += win_chartabsize(curwin, oldp + col + oldlen, vcol); // Don't need to remove a TAB that takes us to the right // position. if (vcol > new_vcol && oldp[col + oldlen] == TAB) { diff --git a/src/nvim/charset.c b/src/nvim/charset.c index e2d844a351..eeeea3f8f6 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -749,12 +749,7 @@ int vim_strnsize(char_u *s, int len) return ptr2cells(p); \ } -int chartabsize(char_u *p, colnr_T col) -{ - RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, p, col) -} - -static int win_chartabsize(win_T *wp, char_u *p, colnr_T col) +int win_chartabsize(win_T *wp, char_u *p, colnr_T col) { RET_WIN_BUF_CHARTABSIZE(wp, wp->w_buffer, p, col) } @@ -936,7 +931,7 @@ bool vim_isprintc_strict(int c) return c > 0 && (g_chartab[c] & CT_PRINT_CHAR); } -/// like chartabsize(), but also check for line breaks on the screen +/// like win_chartabsize(), but also check for line breaks on the screen /// /// @param line /// @param s diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 2305faa20c..e0bb61da07 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -7187,7 +7187,7 @@ static void replace_do_bs(int limit_col) // Get the number of screen cells used by the character we are // going to delete. getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); - orig_vcols = chartabsize(get_cursor_pos_ptr(), start_vcol); + orig_vcols = win_chartabsize(curwin, get_cursor_pos_ptr(), start_vcol); } (void)del_char_after_col(limit_col); if (l_State & VREPLACE_FLAG) { @@ -7202,7 +7202,7 @@ static void replace_do_bs(int limit_col) ins_len = (int)STRLEN(p) - orig_len; vcol = start_vcol; for (i = 0; i < ins_len; ++i) { - vcol += chartabsize(p + i, vcol); + vcol += win_chartabsize(curwin, p + i, vcol); i += (*mb_ptr2len)(p) - 1; } vcol -= start_vcol; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 21c858373c..27a680dc21 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1055,7 +1055,7 @@ static void f_col(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (virtual_active() && fp == &curwin->w_cursor) { char_u *p = get_cursor_pos_ptr(); - if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p, + if (curwin->w_cursor.coladd >= (colnr_T)win_chartabsize(curwin, p, curwin->w_virtcol - curwin->w_cursor.coladd)) { int l; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3ad1fb1adc..deb0dcfe0b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -828,7 +828,7 @@ void ex_retab(exarg_T *eap) } if (ptr[col] == NUL) break; - vcol += chartabsize(ptr + col, (colnr_T)vcol); + vcol += win_chartabsize(curwin, ptr + col, (colnr_T)vcol); col += utfc_ptr2len(ptr + col); } if (new_line == NULL) /* out of memory */ diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 0864dad27d..c46222460b 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -525,7 +525,7 @@ static colnr_T scroll_line_len(linenr_T lnum) char_u *line = ml_get(lnum); if (*line != NUL) { for (;;) { - int numchar = chartabsize(line, col); + int numchar = win_chartabsize(curwin, line, col); MB_PTR_ADV(line); if (*line == NUL) { // don't count the last character break; @@ -621,7 +621,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // scanned *up to* `col`, nudging it left or right when concealed characters // are encountered. // - // chartabsize() is used to keep track of the virtual column position relative + // win_chartabsize() is used to keep track of the virtual column position relative // to the line's bytes. For example: if col == 9 and the line starts with a // tab that's 8 columns wide, we would want the cursor to be highlighting the // second byte, not the ninth. @@ -648,7 +648,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) // checked for concealed characters. vcol = 0; while (vcol < offset && *ptr != NUL) { - vcol += chartabsize(ptr, vcol); + vcol += win_chartabsize(curwin, ptr, vcol); ptr += utfc_ptr2len(ptr); } @@ -659,7 +659,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) vcol = offset; ptr_end = ptr_row_offset; while (vcol < col && *ptr_end != NUL) { - vcol += chartabsize(ptr_end, vcol); + vcol += win_chartabsize(curwin, ptr_end, vcol); ptr_end += utfc_ptr2len(ptr_end); } @@ -674,7 +674,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col) #define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end) while (ptr < ptr_end && *ptr != NUL) { - cwidth = chartabsize(ptr, vcol); + cwidth = win_chartabsize(curwin, ptr, vcol); vcol += cwidth; if (cwidth > 1 && *ptr == '\t' && nudge > 0) { // A tab will "absorb" any previous adjustments. |