0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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.
@@ -5463,7 +5463,6 @@ ex_drop(exarg_T *eap)
eap->cmdidx = CMD_first;
ex_rewind(eap);
}
}
/*
* Skip over the pattern argument of ":vimgrep /pat/[g][j]".
@@ -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)
@@ -5604,5 +5605,4 @@ ex_oldfiles(exarg_T *eap UNUSED)
}
# endif
}
}
#endif

View File

@@ -135,20 +135,20 @@ 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
@@ -785,8 +786,6 @@ ex_compiler(exarg_T *eap)
do_unlet((char_u *)"g:current_compiler", TRUE);
}
}
}
}
#endif
#if defined(FEAT_PYTHON3) || defined(FEAT_PYTHON) || defined(PROTO)

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)
{
@@ -6252,8 +6261,6 @@ ex_tabclose(exarg_T *eap)
else if (!text_locked() && !curbuf_locked())
tabpage_close(eap->forceit);
}
}
}
/*
* ":tabonly": close all tab pages except the current one
@@ -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.
@@ -6293,8 +6310,6 @@ ex_tabonly(exarg_T *eap)
break;
}
}
}
}
/*
* Close the current tab page.
@@ -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
@@ -6400,7 +6416,6 @@ ex_hide(exarg_T *eap UNUSED)
win_close(win, FALSE);
}
}
}
/*
* ":stop" and ":suspend": Suspend Vim.
@@ -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);
@@ -6431,7 +6447,6 @@ ex_stop(exarg_T *eap)
shell_resized(); // may have resized window
apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
}
}
/*
* ":exit", ":xit" and ":wq": Write file and quit the current window.
@@ -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;
@@ -7471,7 +7488,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)
@@ -7693,7 +7711,6 @@ ex_cd(exarg_T *eap)
ex_pwd(eap);
}
}
}
/*
* ":pwd".
@@ -8155,9 +8172,9 @@ ex_at(exarg_T *eap)
== FAIL)
{
beep_flush();
return;
}
else
{
int save_efr = exec_from_reg;
exec_from_reg = TRUE;
@@ -8172,7 +8189,6 @@ ex_at(exarg_T *eap)
exec_from_reg = save_efr;
}
}
/*
* ":!".
@@ -8560,11 +8576,17 @@ 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);
@@ -8572,7 +8594,6 @@ ex_mark(exarg_T *eap)
emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
curwin->w_cursor = pos; // restore curwin->w_cursor
}
}
/*
* Update w_topline, w_leftcol and the cursor position.
@@ -9685,10 +9706,10 @@ 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;
@@ -9696,7 +9717,6 @@ ex_setfiletype(exarg_T *eap)
if (arg != eap->arg)
did_filetype = FALSE;
}
}
static void
ex_digraphs(exarg_T *eap UNUSED)

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;
@@ -398,7 +399,6 @@ finish_incsearch_highlighting(
if (call_update_screen)
update_screen(UPD_SOME_VALID);
}
}
/*
* Do 'incsearch' highlighting if desired.
@@ -4032,14 +4032,14 @@ 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;
}
}
/*
* For each file name in files[num_files]:

View File

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