This commit is contained in:
Jan Edmund Lazo 2018-08-23 04:13:29 -04:00
parent 27fbffeb4f
commit 6c8851be4e
5 changed files with 40 additions and 36 deletions

View File

@ -6919,7 +6919,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
p = look + STRLEN(look); p = look + STRLEN(look);
if ((try_match || try_match_word) if ((try_match || try_match_word)
&& curwin->w_cursor.col >= (colnr_T)(p - look)) { && curwin->w_cursor.col >= (colnr_T)(p - look)) {
int match = FALSE; bool match = false;
if (keytyped == KEY_COMPLETE) { if (keytyped == KEY_COMPLETE) {
char_u *s; char_u *s;
@ -6944,28 +6944,30 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
&& (icase && (icase
? mb_strnicmp(s, look, (size_t)(p - look)) ? mb_strnicmp(s, look, (size_t)(p - look))
: STRNCMP(s, look, p - look)) == 0) : STRNCMP(s, look, p - look)) == 0)
match = TRUE; match = true;
} else } else {
/* TODO: multi-byte */ // TODO(@brammool): multi-byte
if (keytyped == (int)p[-1] || (icase && keytyped < 256 if (keytyped == (int)p[-1]
&& TOLOWER_LOC(keytyped) == || (icase && keytyped < 256
TOLOWER_LOC((int)p[-1]))) { && TOLOWER_LOC(keytyped) == TOLOWER_LOC((int)p[-1]))) {
line = get_cursor_pos_ptr(); line = get_cursor_pos_ptr();
assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX); assert(p >= look && (uintmax_t)(p - look) <= SIZE_MAX);
if ((curwin->w_cursor.col == (colnr_T)(p - look) if ((curwin->w_cursor.col == (colnr_T)(p - look)
|| !vim_iswordc(line[-(p - look) - 1])) || !vim_iswordc(line[-(p - look) - 1]))
&& (icase && (icase
? mb_strnicmp(line - (p - look), look, (size_t)(p - look)) ? mb_strnicmp(line - (p - look), look, (size_t)(p - look))
: STRNCMP(line - (p - look), look, p - look)) : STRNCMP(line - (p - look), look, p - look)) == 0) {
== 0) match = true;
match = TRUE; }
}
} }
if (match && try_match_word && !try_match) { if (match && try_match_word && !try_match) {
/* "0=word": Check if there are only blanks before the /* "0=word": Check if there are only blanks before the
* word. */ * word. */
if (getwhitecols(line) != if (getwhitecols(line) !=
(int)(curwin->w_cursor.col - (p - look))) (int)(curwin->w_cursor.col - (p - look))) {
match = FALSE; match = false;
}
} }
if (match) { if (match) {
return true; return true;

View File

@ -1409,9 +1409,10 @@ static pos_T *find_start_brace(void)
&& (pos = ind_find_start_CORS(NULL)) == NULL) { // XXX && (pos = ind_find_start_CORS(NULL)) == NULL) { // XXX
break; break;
} }
if (pos != NULL) if (pos != NULL) {
curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.lnum = pos->lnum;
} }
}
curwin->w_cursor = cursor_save; curwin->w_cursor = cursor_save;
return trypos; return trypos;
} }
@ -2066,7 +2067,7 @@ int get_c_indent(void)
} }
curwin->w_cursor.lnum = lnum; 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) { if ((trypos = ind_find_start_CORS(NULL)) != NULL) {
lnum = trypos->lnum + 1; lnum = trypos->lnum + 1;
continue; continue;
@ -2588,10 +2589,9 @@ int get_c_indent(void)
break; break;
} }
/* // If we're in a comment or raw string now, skip to the start
* If we're in a comment or raw string now, skip to the start // of it.
* of it. // XXX
*/ /* XXX */
if ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL) { if ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL) {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;
@ -3359,10 +3359,9 @@ term_again:
l = get_cursor_line_ptr(); l = get_cursor_line_ptr();
/* // If we're in a comment or raw string now, skip to the start
* If we're in a comment or raw string now, skip to the start // of it.
* of it. // XXX
*/ /* XXX */
if ((trypos = ind_find_start_CORS(NULL)) != NULL) { if ((trypos = ind_find_start_CORS(NULL)) != NULL) {
curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.lnum = trypos->lnum + 1;
curwin->w_cursor.col = 0; curwin->w_cursor.col = 0;

View File

@ -2049,8 +2049,9 @@ void op_insert(oparg_T *oap, long count1)
ind_pre = (colnr_T)getwhitecols_curline(); ind_pre = (colnr_T)getwhitecols_curline();
firstline = ml_get(oap->start.lnum) + bd.textcol; firstline = ml_get(oap->start.lnum) + bd.textcol;
if (oap->op_type == OP_APPEND) if (oap->op_type == OP_APPEND) {
firstline += bd.textlen; firstline += bd.textlen;
}
pre_textlen = (long)STRLEN(firstline); pre_textlen = (long)STRLEN(firstline);
} }
@ -4133,7 +4134,7 @@ format_lines (
(void)del_bytes(next_leader_len, false, false); (void)del_bytes(next_leader_len, false, false);
mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L, mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
(long)-next_leader_len); (long)-next_leader_len);
} else if (second_indent > 0) { /* the "leader" for FO_Q_SECOND */ } else if (second_indent > 0) { // the "leader" for FO_Q_SECOND
int indent = (int)getwhitecols_curline(); int indent = (int)getwhitecols_curline();
if (indent > 0) { if (indent > 0) {

View File

@ -2460,9 +2460,10 @@ win_line (
ptr = line; ptr = line;
if (has_spell) { if (has_spell) {
/* For checking first word with a capital skip white space. */ // For checking first word with a capital skip white space.
if (cap_col == 0) if (cap_col == 0) {
cap_col = (int)getwhitecols(line); cap_col = (int)getwhitecols(line);
}
/* To be able to spell-check over line boundaries copy the end of the /* 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 * current line into nextline[]. Above the start of the next line was

View File

@ -1398,13 +1398,14 @@ spell_move_to (
capcol = 0; capcol = 0;
// For checking first word with a capital skip white space. // For checking first word with a capital skip white space.
if (capcol == 0) if (capcol == 0) {
capcol = (int)getwhitecols(line); capcol = (int)getwhitecols(line);
else if (curline && wp == curwin) { } else if (curline && wp == curwin) {
// For spellbadword(): check if first word needs a capital. // For spellbadword(): check if first word needs a capital.
col = (int)getwhitecols(line); col = (int)getwhitecols(line);
if (check_need_cap(lnum, col)) if (check_need_cap(lnum, col)) {
capcol = col; capcol = col;
}
// Need to get the line again, may have looked at the previous // Need to get the line again, may have looked at the previous
// one. // one.