diff options
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 8e2c23b006..97975c037b 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -817,9 +817,9 @@ int searchit( pos->lnum, FALSE)); } } else { - --pos->col; + pos->col--; if (pos->lnum <= buf->b_ml.ml_line_count) { - ptr = ml_get_buf(buf, pos->lnum, FALSE); + ptr = ml_get_buf(buf, pos->lnum, false); pos->col -= utf_head_off(ptr, ptr + pos->col); } } @@ -1441,14 +1441,15 @@ int searchc(cmdarg_T *cap, int t_cmd) } if (t_cmd) { - /* backup to before the character (possibly double-byte) */ + // Backup to before the character (possibly double-byte). col -= dir; - if (dir < 0) - /* Landed on the search char which is lastc_bytelen long */ + if (dir < 0) { + // Landed on the search char which is lastc_bytelen long. col += lastc_bytelen - 1; - else - /* To previous char, which may be multi-byte. */ + } else { + // To previous char, which may be multi-byte. col -= utf_head_off(p, p + col); + } } curwin->w_cursor.col = col; @@ -1469,21 +1470,21 @@ pos_T *findmatch(oparg_T *oap, int initc) return findmatchlimit(oap, initc, 0, 0); } -/* - * Return TRUE if the character before "linep[col]" equals "ch". - * Return FALSE if "col" is zero. - * Update "*prevcol" to the column of the previous character, unless "prevcol" - * is NULL. - * Handles multibyte string correctly. - */ -static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) +// Return true if the character before "linep[col]" equals "ch". +// Return false if "col" is zero. +// Update "*prevcol" to the column of the previous character, unless "prevcol" +// is NULL. +// Handles multibyte string correctly. +static bool check_prevcol(char_u *linep, int col, int ch, int *prevcol) { - --col; - if (col > 0) + col--; + if (col > 0) { col -= utf_head_off(linep, linep + col); - if (prevcol) + } + if (prevcol) { *prevcol = col; - return (col >= 0 && linep[col] == ch) ? TRUE : FALSE; + } + return (col >= 0 && linep[col] == ch) ? true : false; } /* @@ -1790,7 +1791,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) if (lisp && comment_col != MAXCOL) pos.col = comment_col; } else { - --pos.col; + pos.col--; pos.col -= utf_head_off(linep, linep + pos.col); } } else { /* forward search */ @@ -2381,8 +2382,7 @@ findpar ( // motion inclusive. if ((curwin->w_cursor.col = (colnr_T)STRLEN(line)) != 0) { curwin->w_cursor.col--; - curwin->w_cursor.col -= - utf_head_off(line, line + curwin->w_cursor.col); + curwin->w_cursor.col -= utf_head_off(line, line + curwin->w_cursor.col); *pincl = true; } } else @@ -3687,7 +3687,7 @@ find_prev_quote( int n; while (col_start > 0) { - --col_start; + col_start--; col_start -= utf_head_off(line, line + col_start); n = 0; if (escape != NULL) |