vim-patch:8.2.4704: using "else" after return or break increases indent (#18032)

Problem:    Using "else" after return or break increases indent.
Solution:   Remove "else" and reduce indent. (Goc Dundar, closes vim/vim#10099)
f26c16144d
This commit is contained in:
zeertzjq
2022-04-08 10:25:22 +08:00
committed by GitHub
parent 4c9a71c69e
commit 356baae80a
4 changed files with 170 additions and 180 deletions

View File

@@ -1015,7 +1015,8 @@ retry:
} }
read_buf_col += n; read_buf_col += n;
break; break;
} else { }
// Append whole line and new-line. Change NL // Append whole line and new-line. Change NL
// to NUL to reverse the effect done below. // to NUL to reverse the effect done below.
for (ni = 0; ni < n; ni++) { for (ni = 0; ni < n; ni++) {
@@ -1031,14 +1032,13 @@ retry:
// When the last line didn't have an // When the last line didn't have an
// end-of-line don't add it now either. // end-of-line don't add it now either.
if (!curbuf->b_p_eol) { if (!curbuf->b_p_eol) {
--tlen; tlen--;
} }
size = tlen; size = tlen;
break; break;
} }
} }
} }
}
} else { } else {
/* /*
* Read bytes from the file. * Read bytes from the file.

View File

@@ -2327,16 +2327,16 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
* We are finished, break the loop here. * We are finished, break the loop here.
*/ */
break; break;
} else { // pointer block full }
/* // pointer block full
* split the pointer block //
* allocate a new pointer block // split the pointer block
* move some of the pointer into the new block // allocate a new pointer block
* prepare for updating the parent block // move some of the pointer into the new block
*/ // prepare for updating the parent block
for (;;) { // do this twice when splitting block 1 for (;;) { // do this twice when splitting block 1
hp_new = ml_new_ptr(mfp); hp_new = ml_new_ptr(mfp);
if (hp_new == NULL) { // TODO: try to fix tree if (hp_new == NULL) { // TODO(vim): try to fix tree
return FAIL; return FAIL;
} }
pp_new = hp_new->bh_data; pp_new = hp_new->bh_data;
@@ -2345,12 +2345,10 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
break; break;
} }
/* // if block 1 becomes full the tree is given an extra level
* if block 1 becomes full the tree is given an extra level // The pointers from block 1 are moved into the new block.
* The pointers from block 1 are moved into the new block. // block 1 is updated to point to the new block
* block 1 is updated to point to the new block // then continue to split the new block
* then continue to split the new block
*/
memmove(pp_new, pp, (size_t)page_size); memmove(pp_new, pp, (size_t)page_size);
pp->pb_count = 1; pp->pb_count = 1;
pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum; pp->pb_pointer[0].pe_bnum = hp_new->bh_bnum;
@@ -2362,12 +2360,10 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
pp = pp_new; pp = pp_new;
CHECK(stack_idx != 0, _("stack_idx should be 0")); CHECK(stack_idx != 0, _("stack_idx should be 0"));
ip->ip_index = 0; ip->ip_index = 0;
++stack_idx; // do block 1 again later stack_idx++; // do block 1 again later
} }
/* // move the pointers after the current one to the new block
* move the pointers after the current one to the new block // If there are none, the new entry will be in the new block.
* If there are none, the new entry will be in the new block.
*/
total_moved = pp->pb_count - pb_idx - 1; total_moved = pp->pb_count - pb_idx - 1;
if (total_moved) { if (total_moved) {
memmove(&pp_new->pb_pointer[0], memmove(&pp_new->pb_pointer[0],
@@ -2397,15 +2393,13 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
lnum_left = 0; lnum_left = 0;
lnum_right = 0; lnum_right = 0;
/* // recompute line counts
* recompute line counts
*/
line_count_right = 0; line_count_right = 0;
for (i = 0; i < (int)pp_new->pb_count; ++i) { for (i = 0; i < (int)pp_new->pb_count; i++) {
line_count_right += pp_new->pb_pointer[i].pe_line_count; line_count_right += pp_new->pb_pointer[i].pe_line_count;
} }
line_count_left = 0; line_count_left = 0;
for (i = 0; i < (int)pp->pb_count; ++i) { for (i = 0; i < (int)pp->pb_count; i++) {
line_count_left += pp->pb_pointer[i].pe_line_count; line_count_left += pp->pb_pointer[i].pe_line_count;
} }
@@ -2416,7 +2410,6 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char_u *line, colnr_T len, b
mf_put(mfp, hp, true, false); mf_put(mfp, hp, true, false);
mf_put(mfp, hp_new, true, false); mf_put(mfp, hp_new, true, false);
} }
}
/* /*
* Safety check: fallen out of for loop? * Safety check: fallen out of for loop?

View File

@@ -5140,7 +5140,8 @@ char *set_option_value(const char *const name, const long number, const char *co
s = ""; s = "";
} }
return set_string_option(opt_idx, s, opt_flags); return set_string_option(opt_idx, s, opt_flags);
} else { }
varp = get_varp_scope(&(options[opt_idx]), opt_flags); varp = get_varp_scope(&(options[opt_idx]), opt_flags);
if (varp != NULL) { // hidden option is not changed if (varp != NULL) { // hidden option is not changed
if (number == 0 && string != NULL) { if (number == 0 && string != NULL) {
@@ -5178,7 +5179,6 @@ char *set_option_value(const char *const name, const long number, const char *co
} }
} }
} }
}
return NULL; return NULL;
} }

View File

@@ -2289,7 +2289,8 @@ static void check_state_ends(void)
next_match_idx = 0; next_match_idx = 0;
next_match_col = MAXCOL; next_match_col = MAXCOL;
break; break;
} else { }
// handle next_list, unless at end of line and no "skipnl" or // handle next_list, unless at end of line and no "skipnl" or
// "skipempty" // "skipempty"
current_next_list = cur_si->si_next_list; current_next_list = cur_si->si_next_list;
@@ -2318,18 +2319,15 @@ static void check_state_ends(void)
cur_si = &CUR_STATE(current_state.ga_len - 1); cur_si = &CUR_STATE(current_state.ga_len - 1);
/* // Only for a region the search for the end continues after
* Only for a region the search for the end continues after // the end of the contained item. If the contained match
* the end of the contained item. If the contained match // included the end-of-line, break here, the region continues.
* included the end-of-line, break here, the region continues. // Don't do this when:
* Don't do this when: // - "keepend" is used for the contained item
* - "keepend" is used for the contained item // - not at the end of the line (could be end="x$"me=e-1).
* - not at the end of the line (could be end="x$"me=e-1). // - "excludenl" is used (HL_HAS_EOL won't be set)
* - "excludenl" is used (HL_HAS_EOL won't be set)
*/
if (cur_si->si_idx >= 0 if (cur_si->si_idx >= 0
&& SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type == SPTYPE_START
== SPTYPE_START
&& !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) { && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) {
update_si_end(cur_si, (int)current_col, true); update_si_end(cur_si, (int)current_col, true);
check_keepend(); check_keepend();
@@ -2339,7 +2337,6 @@ static void check_state_ends(void)
break; break;
} }
} }
}
} else { } else {
break; break;
} }