1
0
forked from aniani/vim

patch 9.0.1115: code is indented more than needed

Problem:    Code is indented more than needed.
Solution:   Use an early return to reduce indenting. (Yegappan Lakshmanan,
            closes #11758)
This commit is contained in:
Yegappan Lakshmanan
2022-12-30 18:07:46 +00:00
committed by Bram Moolenaar
parent ef91ae4557
commit ed0c1d5d4b
5 changed files with 379 additions and 358 deletions

View File

@@ -5413,9 +5413,9 @@ ex_drop(exarg_T *eap)
// edited in a window yet. It's like ":tab all" but without closing
// windows or tabs.
ex_all(eap);
return;
}
else
{
// ":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.
@@ -5462,7 +5462,6 @@ ex_drop(exarg_T *eap)
else
eap->cmdidx = CMD_first;
ex_rewind(eap);
}
}
/*
@@ -5556,9 +5555,11 @@ ex_oldfiles(exarg_T *eap UNUSED)
char_u *fname;
if (l == NULL)
msg(_("No old files"));
else
{
msg(_("No old files"));
return;
}
msg_start();
msg_scroll = TRUE;
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
@@ -5603,6 +5604,5 @@ ex_oldfiles(exarg_T *eap UNUSED)
}
}
# endif
}
}
#endif

View File

@@ -135,19 +135,19 @@ check_changed(buf_T *buf, int flags)
void
browse_save_fname(buf_T *buf)
{
if (buf->b_fname == NULL)
{
if (buf->b_fname != NULL)
return;
char_u *fname;
fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
NULL, NULL, NULL, NULL, buf);
if (fname != NULL)
{
if (fname == NULL)
return;
if (setfname(buf, fname, NULL, TRUE) == OK)
buf->b_flags |= BF_NOTEDITED;
vim_free(fname);
}
}
}
#endif
@@ -731,12 +731,13 @@ ex_compiler(exarg_T *eap)
// List all compiler scripts.
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
// ) keep the indenter happy...
return;
}
else
{
buf = alloc(STRLEN(eap->arg) + 14);
if (buf != NULL)
{
if (buf == NULL)
return;
if (eap->forceit)
{
// ":compiler! {name}" sets global options
@@ -784,8 +785,6 @@ ex_compiler(exarg_T *eap)
else
do_unlet((char_u *)"g:current_compiler", TRUE);
}
}
}
}
#endif

View File

@@ -1739,7 +1739,6 @@ do_one_cmd(
char_u *cmd;
int starts_with_colon = FALSE;
int may_have_range;
int vim9script;
#ifdef FEAT_EVAL
int did_set_expr_line = FALSE;
#endif
@@ -1807,7 +1806,7 @@ do_one_cmd(
// In Vim9 script a colon is required before the range. This may also be
// after command modifiers.
vim9script = in_vim9script();
int vim9script = in_vim9script();
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
{
may_have_range = FALSE;
@@ -6230,14 +6229,24 @@ ex_tabclose(exarg_T *eap)
int tab_number;
if (cmdwin_type != 0)
{
cmdwin_result = K_IGNORE;
else if (first_tabpage->tp_next == NULL)
return;
}
if (first_tabpage->tp_next == NULL)
{
emsg(_(e_cannot_close_last_tab_page));
else if (!window_layout_locked(CMD_tabclose))
{
return;
}
if (window_layout_locked(CMD_tabclose))
return;
tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL)
{
if (eap->errmsg != NULL)
return;
tp = find_tabpage(tab_number);
if (tp == NULL)
{
@@ -6251,8 +6260,6 @@ ex_tabclose(exarg_T *eap)
}
else if (!text_locked() && !curbuf_locked())
tabpage_close(eap->forceit);
}
}
}
/*
@@ -6266,14 +6273,24 @@ ex_tabonly(exarg_T *eap)
int tab_number;
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 if (!window_layout_locked(CMD_tabonly))
{
return;
}
if (window_layout_locked(CMD_tabonly))
return;
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.
@@ -6292,8 +6309,6 @@ ex_tabonly(exarg_T *eap)
if (first_tabpage->tp_next == NULL)
break;
}
}
}
}
/*
@@ -6375,8 +6390,9 @@ ex_only(exarg_T *eap)
ex_hide(exarg_T *eap UNUSED)
{
// ":hide" or ":hide | cmd": hide current window
if (!eap->skip)
{
if (eap->skip)
return;
if (window_layout_locked(CMD_hide))
return;
#ifdef FEAT_GUI
@@ -6399,7 +6415,6 @@ ex_hide(exarg_T *eap UNUSED)
win = lastwin;
win_close(win, FALSE);
}
}
}
/*
@@ -6411,8 +6426,9 @@ ex_stop(exarg_T *eap)
/*
* Disallow suspending for "rvim".
*/
if (!check_restricted())
{
if (check_restricted())
return;
if (!eap->forceit)
autowrite_all();
apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
@@ -6430,7 +6446,6 @@ ex_stop(exarg_T *eap)
redraw_later_clear();
shell_resized(); // may have resized window
apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
}
}
/*
@@ -7403,9 +7418,11 @@ ex_read(exarg_T *eap)
linenr_T lnum;
if (eap->usefilter) // :r!cmd
do_bang(1, eap, FALSE, FALSE, TRUE);
else
{
do_bang(1, eap, FALSE, FALSE, TRUE);
return;
}
if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
return;
@@ -7470,7 +7487,6 @@ ex_read(exarg_T *eap)
}
redraw_curbuf_later(UPD_VALID);
}
}
}
static char_u *prev_dir = NULL;
@@ -7675,10 +7691,12 @@ ex_cd(exarg_T *eap)
#if !defined(UNIX) && !defined(VMS)
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
if (*new_dir == NUL && !p_cdh)
ex_pwd(NULL);
else
#endif
{
ex_pwd(NULL);
return;
}
#endif
cdscope_T scope = CDSCOPE_GLOBAL;
if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
@@ -7692,7 +7710,6 @@ ex_cd(exarg_T *eap)
if (KeyTyped || p_verbose >= 5)
ex_pwd(eap);
}
}
}
/*
@@ -8155,9 +8172,9 @@ ex_at(exarg_T *eap)
== FAIL)
{
beep_flush();
return;
}
else
{
int save_efr = exec_from_reg;
exec_from_reg = TRUE;
@@ -8171,7 +8188,6 @@ ex_at(exarg_T *eap)
(void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
exec_from_reg = save_efr;
}
}
/*
@@ -8560,18 +8576,23 @@ ex_mark(exarg_T *eap)
return;
#endif
if (*eap->arg == NUL) // No argument?
emsg(_(e_argument_required));
else if (eap->arg[1] != NUL) // more than one character?
semsg(_(e_trailing_characters_str), eap->arg);
else
{
emsg(_(e_argument_required));
return;
}
if (eap->arg[1] != NUL) // more than one character?
{
semsg(_(e_trailing_characters_str), eap->arg);
return;
}
pos = curwin->w_cursor; // save curwin->w_cursor
curwin->w_cursor.lnum = eap->line2;
beginline(BL_WHITE | BL_FIX);
if (setmark(*eap->arg) == FAIL) // set mark
emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
curwin->w_cursor = pos; // restore curwin->w_cursor
}
}
/*
@@ -9685,17 +9706,16 @@ ex_filetype(exarg_T *eap)
static void
ex_setfiletype(exarg_T *eap)
{
if (!did_filetype)
{
char_u *arg = eap->arg;
if (did_filetype)
return;
char_u *arg = eap->arg;
if (STRNCMP(arg, "FALLBACK ", 9) == 0)
arg += 9;
set_option_value_give_err((char_u *)"filetype", 0L, arg, OPT_LOCAL);
if (arg != eap->arg)
did_filetype = FALSE;
}
}
static void

View File

@@ -368,8 +368,9 @@ finish_incsearch_highlighting(
incsearch_state_T *is_state,
int call_update_screen)
{
if (is_state->did_incsearch)
{
if (!is_state->did_incsearch)
return;
is_state->did_incsearch = FALSE;
if (gotesc)
curwin->w_cursor = is_state->save_cursor;
@@ -397,7 +398,6 @@ finish_incsearch_highlighting(
redraw_all_later(UPD_SOME_VALID);
if (call_update_screen)
update_screen(UPD_SOME_VALID);
}
}
/*
@@ -4032,13 +4032,13 @@ escape_fname(char_u **pp)
char_u *p;
p = alloc(STRLEN(*pp) + 2);
if (p != NULL)
{
if (p == NULL)
return;
p[0] = '\\';
STRCPY(p + 1, *pp);
vim_free(*pp);
*pp = p;
}
}
/*

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1115,
/**/
1114,
/**/