diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/edit.c | 38 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 19 | ||||
-rw-r--r-- | src/nvim/ops.c | 7 | ||||
-rw-r--r-- | src/nvim/screen.c | 5 | ||||
-rw-r--r-- | src/nvim/spell.c | 7 |
5 files changed, 40 insertions, 36 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index be2797ee3e..08b74249ba 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -6919,7 +6919,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) p = look + STRLEN(look); if ((try_match || try_match_word) && curwin->w_cursor.col >= (colnr_T)(p - look)) { - int match = FALSE; + bool match = false; if (keytyped == KEY_COMPLETE) { char_u *s; @@ -6944,28 +6944,30 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty) && (icase ? mb_strnicmp(s, look, (size_t)(p - look)) : STRNCMP(s, look, p - look)) == 0) - match = TRUE; - } else - /* TODO: multi-byte */ - if (keytyped == (int)p[-1] || (icase && keytyped < 256 - && TOLOWER_LOC(keytyped) == - TOLOWER_LOC((int)p[-1]))) { - line = get_cursor_pos_ptr(); - assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); - if ((curwin->w_cursor.col == (colnr_T)(p - look) - || !vim_iswordc(line[-(p - look) - 1])) - && (icase - ? mb_strnicmp(line - (p - look), look, (size_t)(p - look)) - : STRNCMP(line - (p - look), look, p - look)) - == 0) - match = TRUE; + match = true; + } else { + // TODO(@brammool): multi-byte + if (keytyped == (int)p[-1] + || (icase && keytyped < 256 + && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) { + line = get_cursor_pos_ptr(); + assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); + if ((curwin->w_cursor.col == (colnr_T)(p - look) + || !vim_iswordc(line[-(p - look) - 1])) + && (icase + ? mb_strnicmp(line - (p - look), look, (size_t)(p - look)) + : STRNCMP(line - (p - look), look, p - look)) == 0) { + match = true; + } + } } if (match && try_match_word && !try_match) { /* "0=word": Check if there are only blanks before the * word. */ if (getwhitecols(line) != - (int)(curwin->w_cursor.col - (p - look))) - match = FALSE; + (int)(curwin->w_cursor.col - (p - look))) { + match = false; + } } if (match) { return true; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index c1aeb4cab8..f8ce6200d7 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1409,8 +1409,9 @@ static pos_T *find_start_brace(void) && (pos = ind_find_start_CORS(NULL)) == NULL) { // XXX break; } - if (pos != NULL) + if (pos != NULL) { curwin->w_cursor.lnum = pos->lnum; + } } curwin->w_cursor = cursor_save; return trypos; @@ -2066,7 +2067,7 @@ int get_c_indent(void) } curwin->w_cursor.lnum = lnum; - /* Skip a comment or raw string. XXX */ + // Skip a comment or raw string. XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { lnum = trypos->lnum + 1; continue; @@ -2588,10 +2589,9 @@ int get_c_indent(void) break; } - /* - * If we're in a comment or raw string now, skip to the start - * of it. - */ /* XXX */ + // If we're in a comment or raw string now, skip to the start + // of it. + // XXX if ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; @@ -3359,10 +3359,9 @@ term_again: l = get_cursor_line_ptr(); - /* - * If we're in a comment or raw string now, skip to the start - * of it. - */ /* XXX */ + // If we're in a comment or raw string now, skip to the start + // of it. + // XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index d6f60f33da..9e837c1e12 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2049,8 +2049,9 @@ void op_insert(oparg_T *oap, long count1) ind_pre = (colnr_T)getwhitecols_curline(); firstline = ml_get(oap->start.lnum) + bd.textcol; - if (oap->op_type == OP_APPEND) + if (oap->op_type == OP_APPEND) { firstline += bd.textlen; + } pre_textlen = (long)STRLEN(firstline); } @@ -4132,8 +4133,8 @@ format_lines ( if (next_leader_len > 0) { (void)del_bytes(next_leader_len, false, false); mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, - (long)-next_leader_len); - } else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */ + (long)-next_leader_len); + } else if (second_indent > 0) { // the "leader" for FO_Q_SECOND int indent = (int)getwhitecols_curline(); if (indent > 0) { diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e1bc8556f9..092820321c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2460,9 +2460,10 @@ win_line ( ptr = line; if (has_spell) { - /* For checking first word with a capital skip white space. */ - if (cap_col == 0) + // For checking first word with a capital skip white space. + if (cap_col == 0) { cap_col = (int)getwhitecols(line); + } /* To be able to spell-check over line boundaries copy the end of the * current line into nextline[]. Above the start of the next line was diff --git a/src/nvim/spell.c b/src/nvim/spell.c index c05a1d107a..4acbdcc298 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1398,13 +1398,14 @@ spell_move_to ( capcol = 0; // For checking first word with a capital skip white space. - if (capcol == 0) + if (capcol == 0) { capcol = (int)getwhitecols(line); - else if (curline && wp == curwin) { + } else if (curline && wp == curwin) { // For spellbadword(): check if first word needs a capital. col = (int)getwhitecols(line); - if (check_need_cap(lnum, col)) + if (check_need_cap(lnum, col)) { capcol = col; + } // Need to get the line again, may have looked at the previous // one. |