vim-patch:9.0.1115: code is indented more than needed (#21598)

Problem:    Code is indented more than needed.
Solution:   Use an early return to reduce indenting. (Yegappan Lakshmanan,
            closes vim/vim#11758)

ed0c1d5d4b

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-12-31 06:41:23 +08:00
committed by GitHub
parent 6a45360de9
commit 99cf111289
4 changed files with 291 additions and 263 deletions

View File

@@ -4743,7 +4743,9 @@ void ex_oldfiles(exarg_T *eap)
if (l == NULL) {
msg(_("No old files"));
} else {
return;
}
msg_start();
msg_scroll = true;
TV_LIST_ITER(l, li, {
@@ -4784,7 +4786,6 @@ void ex_oldfiles(exarg_T *eap)
}
}
}
}
void ex_trust(exarg_T *eap)
{

View File

@@ -705,9 +705,12 @@ void ex_compiler(exarg_T *eap)
// List all compiler scripts.
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT
} else {
return;
}
size_t bufsize = strlen(eap->arg) + 14;
buf = xmalloc(bufsize);
if (eap->forceit) {
// ":compiler! {name}" sets global options
do_cmdline_cmd("command -nargs=* CompilerSet set <args>");
@@ -755,7 +758,6 @@ void ex_compiler(exarg_T *eap)
}
}
}
}
/// ":checktime [buffer]"
void ex_checktime(exarg_T *eap)
@@ -847,7 +849,9 @@ void ex_drop(exarg_T *eap)
// edited in a window yet. It's like ":tab all" but without closing
// windows or tabs.
ex_all(eap);
} else {
return;
}
// ":drop file ...": Edit the first argument. Jump to an existing
// window if possible, edit in current window if the current buffer
// can be abandoned, otherwise open a new window.
@@ -888,4 +892,3 @@ void ex_drop(exarg_T *eap)
}
ex_rewind(eap);
}
}

View File

@@ -4663,11 +4663,19 @@ static void ex_tabclose(exarg_T *eap)
{
if (cmdwin_type != 0) {
cmdwin_result = K_IGNORE;
} else if (first_tabpage->tp_next == NULL) {
return;
}
if (first_tabpage->tp_next == NULL) {
emsg(_("E784: Cannot close last tab page"));
} else {
return;
}
int tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL) {
if (eap->errmsg != NULL) {
return;
}
tabpage_T *tp = find_tabpage(tab_number);
if (tp == NULL) {
beep_flush();
@@ -4680,19 +4688,25 @@ static void ex_tabclose(exarg_T *eap)
tabpage_close(eap->forceit);
}
}
}
}
/// ":tabonly": close all tab pages except the current one
static void ex_tabonly(exarg_T *eap)
{
if (cmdwin_type != 0) {
cmdwin_result = K_IGNORE;
} else if (first_tabpage->tp_next == NULL) {
return;
}
if (first_tabpage->tp_next == NULL) {
msg(_("Already only one tab page"));
} else {
return;
}
int tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL) {
if (eap->errmsg != NULL) {
return;
}
goto_tabpage(tab_number);
// Repeat this up to a 1000 times, because autocommands may
// mess up the lists.
@@ -4714,8 +4728,6 @@ static void ex_tabonly(exarg_T *eap)
}
}
}
}
}
/// Close the current tab page.
void tabpage_close(int forceit)
@@ -4782,7 +4794,10 @@ static void ex_only(exarg_T *eap)
static void ex_hide(exarg_T *eap)
{
// ":hide" or ":hide | cmd": hide current window
if (!eap->skip) {
if (eap->skip) {
return;
}
if (eap->addr_count == 0) {
win_close(curwin, false, eap->forceit); // don't free buffer
} else {
@@ -4802,7 +4817,6 @@ static void ex_hide(exarg_T *eap)
win_close(win, false, eap->forceit);
}
}
}
/// ":stop" and ":suspend": Suspend Vim.
static void ex_stop(exarg_T *eap)
@@ -5384,12 +5398,14 @@ static void ex_read(exarg_T *eap)
if (eap->usefilter) { // :r!cmd
do_bang(1, eap, false, false, true);
} else {
return;
}
if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) {
return;
}
int i;
int i;
if (*eap->arg == NUL) {
if (check_fname() == FAIL) { // check for no file name
return;
@@ -5429,7 +5445,6 @@ static void ex_read(exarg_T *eap)
redraw_curbuf_later(UPD_VALID);
}
}
}
static char *prev_dir = NULL;
@@ -5584,6 +5599,7 @@ void ex_cd(exarg_T *eap)
return;
}
#endif
CdScope scope = kCdScopeGlobal;
switch (eap->cmdidx) {
case CMD_tcd:
@@ -5879,8 +5895,10 @@ static void ex_at(exarg_T *eap)
// Put the register in the typeahead buffer with the "silent" flag.
if (do_execreg(c, true, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, true) == FAIL) {
beep_flush();
} else {
bool save_efr = exec_from_reg;
return;
}
const bool save_efr = exec_from_reg;
exec_from_reg = true;
@@ -5893,7 +5911,6 @@ static void ex_at(exarg_T *eap)
exec_from_reg = save_efr;
}
}
/// ":!".
static void ex_bang(exarg_T *eap)
@@ -6222,9 +6239,14 @@ static void ex_mark(exarg_T *eap)
{
if (*eap->arg == NUL) { // No argument?
emsg(_(e_argreq));
} else if (eap->arg[1] != NUL) { // more than one character?
return;
}
if (eap->arg[1] != NUL) { // more than one character?
semsg(_(e_trailing_arg), eap->arg);
} else {
return;
}
pos_T pos = curwin->w_cursor; // save curwin->w_cursor
curwin->w_cursor.lnum = eap->line2;
beginline(BL_WHITE | BL_FIX);
@@ -6233,7 +6255,6 @@ static void ex_mark(exarg_T *eap)
}
curwin->w_cursor = pos; // restore curwin->w_cursor
}
}
/// Update w_topline, w_leftcol and the cursor position.
void update_topline_cursor(void)
@@ -7146,9 +7167,11 @@ void filetype_maybe_enable(void)
/// ":setfiletype [FALLBACK] {name}"
static void ex_setfiletype(exarg_T *eap)
{
if (!did_filetype) {
char *arg = eap->arg;
if (did_filetype) {
return;
}
char *arg = eap->arg;
if (strncmp(arg, "FALLBACK ", 9) == 0) {
arg += 9;
}
@@ -7158,7 +7181,6 @@ static void ex_setfiletype(exarg_T *eap)
did_filetype = false;
}
}
}
static void ex_digraphs(exarg_T *eap)
{

View File

@@ -575,7 +575,10 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s)
static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool call_update_screen)
{
if (s->did_incsearch) {
if (!s->did_incsearch) {
return;
}
s->did_incsearch = false;
if (gotesc) {
curwin->w_cursor = s->save_cursor;
@@ -602,7 +605,6 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
update_screen();
}
}
}
/// Initialize the current command-line info.
static void init_ccline(int firstc, int indent)