aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-08-28 23:37:30 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-08-28 23:37:30 +0200
commita2403a0ed9afdfaea7abb5555dbdf555b56eff9a (patch)
tree74378ce589d267842f018955bbf9daf93bedac13 /src/nvim/edit.c
parentacdede50cebf7d247e55356be828ebaba43c0d3d (diff)
parentd110c6d7907d6f27f32b1d2bd91ffee7ef6097f4 (diff)
downloadrneovim-a2403a0ed9afdfaea7abb5555dbdf555b56eff9a.tar.gz
rneovim-a2403a0ed9afdfaea7abb5555dbdf555b56eff9a.tar.bz2
rneovim-a2403a0ed9afdfaea7abb5555dbdf555b56eff9a.zip
Merge #8863 'refactor: Remove mb_head_off() '
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 08b74249ba..a20661bb16 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1556,14 +1556,11 @@ void display_dollar(colnr_T col)
save_col = curwin->w_cursor.col;
curwin->w_cursor.col = col;
- if (has_mbyte) {
- char_u *p;
- /* If on the last byte of a multi-byte move to the first byte. */
- p = get_cursor_line_ptr();
- curwin->w_cursor.col -= (*mb_head_off)(p, p + col);
- }
- curs_columns(FALSE); /* recompute w_wrow and w_wcol */
+ // If on the last byte of a multi-byte move to the first byte.
+ char_u *p = get_cursor_line_ptr();
+ curwin->w_cursor.col -= utf_head_off(p, p + col);
+ curs_columns(false); // Recompute w_wrow and w_wcol
if (curwin->w_wcol < curwin->w_width) {
edit_putchar('$', FALSE);
dollar_vcol = curwin->w_virtcol;
@@ -3448,10 +3445,10 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
}
if (compl_orig_text != NULL) {
p = compl_orig_text;
- for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len)
- ;
- if (len > 0)
- len -= (*mb_head_off)(p, p + len);
+ for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
+ if (len > 0) {
+ len -= utf_head_off(p, p + len);
+ }
for (p += len; *p != NUL; MB_PTR_ADV(p)) {
AppendCharToRedobuff(K_BS);
}
@@ -4587,24 +4584,17 @@ static int ins_complete(int c, bool enable_pum)
compl_col += curs_col;
compl_length = 0;
} else {
- /* Search the point of change class of multibyte character
- * or not a word single byte character backward. */
- if (has_mbyte) {
- int base_class;
- int head_off;
-
- startcol -= (*mb_head_off)(line, line + startcol);
- base_class = mb_get_class(line + startcol);
- while (--startcol >= 0) {
- head_off = (*mb_head_off)(line, line + startcol);
- if (base_class != mb_get_class(line + startcol
- - head_off))
- break;
- startcol -= head_off;
+ // Search the point of change class of multibyte character
+ // or not a word single byte character backward.
+ startcol -= utf_head_off(line, line + startcol);
+ int base_class = mb_get_class(line + startcol);
+ while (--startcol >= 0) {
+ int head_off = utf_head_off(line, line + startcol);
+ if (base_class != mb_get_class(line + startcol - head_off)) {
+ break;
}
- } else
- while (--startcol >= 0 && vim_iswordc(line[startcol]))
- ;
+ startcol -= head_off;
+ }
compl_col += ++startcol;
compl_length = (int)curs_col - startcol;
if (compl_length == 1) {