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:
committed by
Bram Moolenaar
parent
ef91ae4557
commit
ed0c1d5d4b
@@ -5413,9 +5413,9 @@ ex_drop(exarg_T *eap)
|
|||||||
// edited in a window yet. It's like ":tab all" but without closing
|
// edited in a window yet. It's like ":tab all" but without closing
|
||||||
// windows or tabs.
|
// windows or tabs.
|
||||||
ex_all(eap);
|
ex_all(eap);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// ":drop file ...": Edit the first argument. Jump to an existing
|
// ":drop file ...": Edit the first argument. Jump to an existing
|
||||||
// window if possible, edit in current window if the current buffer
|
// window if possible, edit in current window if the current buffer
|
||||||
// can be abandoned, otherwise open a new window.
|
// can be abandoned, otherwise open a new window.
|
||||||
@@ -5463,7 +5463,6 @@ ex_drop(exarg_T *eap)
|
|||||||
eap->cmdidx = CMD_first;
|
eap->cmdidx = CMD_first;
|
||||||
ex_rewind(eap);
|
ex_rewind(eap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip over the pattern argument of ":vimgrep /pat/[g][j]".
|
* Skip over the pattern argument of ":vimgrep /pat/[g][j]".
|
||||||
@@ -5556,9 +5555,11 @@ ex_oldfiles(exarg_T *eap UNUSED)
|
|||||||
char_u *fname;
|
char_u *fname;
|
||||||
|
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
msg(_("No old files"));
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
msg(_("No old files"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
msg_start();
|
msg_start();
|
||||||
msg_scroll = TRUE;
|
msg_scroll = TRUE;
|
||||||
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
|
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
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -135,20 +135,20 @@ check_changed(buf_T *buf, int flags)
|
|||||||
void
|
void
|
||||||
browse_save_fname(buf_T *buf)
|
browse_save_fname(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (buf->b_fname == NULL)
|
if (buf->b_fname != NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
char_u *fname;
|
char_u *fname;
|
||||||
|
|
||||||
fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
|
fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"),
|
||||||
NULL, NULL, NULL, NULL, buf);
|
NULL, NULL, NULL, NULL, buf);
|
||||||
if (fname != NULL)
|
if (fname == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (setfname(buf, fname, NULL, TRUE) == OK)
|
if (setfname(buf, fname, NULL, TRUE) == OK)
|
||||||
buf->b_flags |= BF_NOTEDITED;
|
buf->b_flags |= BF_NOTEDITED;
|
||||||
vim_free(fname);
|
vim_free(fname);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -731,12 +731,13 @@ ex_compiler(exarg_T *eap)
|
|||||||
// List all compiler scripts.
|
// List all compiler scripts.
|
||||||
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
|
do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')");
|
||||||
// ) keep the indenter happy...
|
// ) keep the indenter happy...
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
buf = alloc(STRLEN(eap->arg) + 14);
|
buf = alloc(STRLEN(eap->arg) + 14);
|
||||||
if (buf != NULL)
|
if (buf == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (eap->forceit)
|
if (eap->forceit)
|
||||||
{
|
{
|
||||||
// ":compiler! {name}" sets global options
|
// ":compiler! {name}" sets global options
|
||||||
@@ -785,8 +786,6 @@ ex_compiler(exarg_T *eap)
|
|||||||
do_unlet((char_u *)"g:current_compiler", TRUE);
|
do_unlet((char_u *)"g:current_compiler", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FEAT_PYTHON3) || defined(FEAT_PYTHON) || defined(PROTO)
|
#if defined(FEAT_PYTHON3) || defined(FEAT_PYTHON) || defined(PROTO)
|
||||||
|
102
src/ex_docmd.c
102
src/ex_docmd.c
@@ -1739,7 +1739,6 @@ do_one_cmd(
|
|||||||
char_u *cmd;
|
char_u *cmd;
|
||||||
int starts_with_colon = FALSE;
|
int starts_with_colon = FALSE;
|
||||||
int may_have_range;
|
int may_have_range;
|
||||||
int vim9script;
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
int did_set_expr_line = FALSE;
|
int did_set_expr_line = FALSE;
|
||||||
#endif
|
#endif
|
||||||
@@ -1807,7 +1806,7 @@ do_one_cmd(
|
|||||||
|
|
||||||
// In Vim9 script a colon is required before the range. This may also be
|
// In Vim9 script a colon is required before the range. This may also be
|
||||||
// after command modifiers.
|
// after command modifiers.
|
||||||
vim9script = in_vim9script();
|
int vim9script = in_vim9script();
|
||||||
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
|
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
|
||||||
{
|
{
|
||||||
may_have_range = FALSE;
|
may_have_range = FALSE;
|
||||||
@@ -6230,14 +6229,24 @@ ex_tabclose(exarg_T *eap)
|
|||||||
int tab_number;
|
int tab_number;
|
||||||
|
|
||||||
if (cmdwin_type != 0)
|
if (cmdwin_type != 0)
|
||||||
|
{
|
||||||
cmdwin_result = K_IGNORE;
|
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));
|
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);
|
tab_number = get_tabpage_arg(eap);
|
||||||
if (eap->errmsg == NULL)
|
if (eap->errmsg != NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
tp = find_tabpage(tab_number);
|
tp = find_tabpage(tab_number);
|
||||||
if (tp == NULL)
|
if (tp == NULL)
|
||||||
{
|
{
|
||||||
@@ -6252,8 +6261,6 @@ ex_tabclose(exarg_T *eap)
|
|||||||
else if (!text_locked() && !curbuf_locked())
|
else if (!text_locked() && !curbuf_locked())
|
||||||
tabpage_close(eap->forceit);
|
tabpage_close(eap->forceit);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":tabonly": close all tab pages except the current one
|
* ":tabonly": close all tab pages except the current one
|
||||||
@@ -6266,14 +6273,24 @@ ex_tabonly(exarg_T *eap)
|
|||||||
int tab_number;
|
int tab_number;
|
||||||
|
|
||||||
if (cmdwin_type != 0)
|
if (cmdwin_type != 0)
|
||||||
|
{
|
||||||
cmdwin_result = K_IGNORE;
|
cmdwin_result = K_IGNORE;
|
||||||
else if (first_tabpage->tp_next == NULL)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (first_tabpage->tp_next == NULL)
|
||||||
|
{
|
||||||
msg(_("Already only one tab page"));
|
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);
|
tab_number = get_tabpage_arg(eap);
|
||||||
if (eap->errmsg == NULL)
|
if (eap->errmsg != NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
goto_tabpage(tab_number);
|
goto_tabpage(tab_number);
|
||||||
// Repeat this up to a 1000 times, because autocommands may
|
// Repeat this up to a 1000 times, because autocommands may
|
||||||
// mess up the lists.
|
// mess up the lists.
|
||||||
@@ -6293,8 +6310,6 @@ ex_tabonly(exarg_T *eap)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the current tab page.
|
* Close the current tab page.
|
||||||
@@ -6375,8 +6390,9 @@ ex_only(exarg_T *eap)
|
|||||||
ex_hide(exarg_T *eap UNUSED)
|
ex_hide(exarg_T *eap UNUSED)
|
||||||
{
|
{
|
||||||
// ":hide" or ":hide | cmd": hide current window
|
// ":hide" or ":hide | cmd": hide current window
|
||||||
if (!eap->skip)
|
if (eap->skip)
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (window_layout_locked(CMD_hide))
|
if (window_layout_locked(CMD_hide))
|
||||||
return;
|
return;
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
@@ -6400,7 +6416,6 @@ ex_hide(exarg_T *eap UNUSED)
|
|||||||
win_close(win, FALSE);
|
win_close(win, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":stop" and ":suspend": Suspend Vim.
|
* ":stop" and ":suspend": Suspend Vim.
|
||||||
@@ -6411,8 +6426,9 @@ ex_stop(exarg_T *eap)
|
|||||||
/*
|
/*
|
||||||
* Disallow suspending for "rvim".
|
* Disallow suspending for "rvim".
|
||||||
*/
|
*/
|
||||||
if (!check_restricted())
|
if (check_restricted())
|
||||||
{
|
return;
|
||||||
|
|
||||||
if (!eap->forceit)
|
if (!eap->forceit)
|
||||||
autowrite_all();
|
autowrite_all();
|
||||||
apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
|
apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
|
||||||
@@ -6431,7 +6447,6 @@ ex_stop(exarg_T *eap)
|
|||||||
shell_resized(); // may have resized window
|
shell_resized(); // may have resized window
|
||||||
apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
|
apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":exit", ":xit" and ":wq": Write file and quit the current window.
|
* ":exit", ":xit" and ":wq": Write file and quit the current window.
|
||||||
@@ -7403,9 +7418,11 @@ ex_read(exarg_T *eap)
|
|||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
|
|
||||||
if (eap->usefilter) // :r!cmd
|
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)
|
if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -7471,7 +7488,6 @@ ex_read(exarg_T *eap)
|
|||||||
redraw_curbuf_later(UPD_VALID);
|
redraw_curbuf_later(UPD_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static char_u *prev_dir = NULL;
|
static char_u *prev_dir = NULL;
|
||||||
|
|
||||||
@@ -7675,10 +7691,12 @@ ex_cd(exarg_T *eap)
|
|||||||
#if !defined(UNIX) && !defined(VMS)
|
#if !defined(UNIX) && !defined(VMS)
|
||||||
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
|
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
|
||||||
if (*new_dir == NUL && !p_cdh)
|
if (*new_dir == NUL && !p_cdh)
|
||||||
ex_pwd(NULL);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
|
ex_pwd(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
cdscope_T scope = CDSCOPE_GLOBAL;
|
cdscope_T scope = CDSCOPE_GLOBAL;
|
||||||
|
|
||||||
if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
|
if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
|
||||||
@@ -7693,7 +7711,6 @@ ex_cd(exarg_T *eap)
|
|||||||
ex_pwd(eap);
|
ex_pwd(eap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":pwd".
|
* ":pwd".
|
||||||
@@ -8155,9 +8172,9 @@ ex_at(exarg_T *eap)
|
|||||||
== FAIL)
|
== FAIL)
|
||||||
{
|
{
|
||||||
beep_flush();
|
beep_flush();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
int save_efr = exec_from_reg;
|
int save_efr = exec_from_reg;
|
||||||
|
|
||||||
exec_from_reg = TRUE;
|
exec_from_reg = TRUE;
|
||||||
@@ -8172,7 +8189,6 @@ ex_at(exarg_T *eap)
|
|||||||
|
|
||||||
exec_from_reg = save_efr;
|
exec_from_reg = save_efr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":!".
|
* ":!".
|
||||||
@@ -8560,11 +8576,17 @@ ex_mark(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (*eap->arg == NUL) // No argument?
|
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
|
pos = curwin->w_cursor; // save curwin->w_cursor
|
||||||
curwin->w_cursor.lnum = eap->line2;
|
curwin->w_cursor.lnum = eap->line2;
|
||||||
beginline(BL_WHITE | BL_FIX);
|
beginline(BL_WHITE | BL_FIX);
|
||||||
@@ -8572,7 +8594,6 @@ ex_mark(exarg_T *eap)
|
|||||||
emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
|
emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
|
||||||
curwin->w_cursor = pos; // restore curwin->w_cursor
|
curwin->w_cursor = pos; // restore curwin->w_cursor
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update w_topline, w_leftcol and the cursor position.
|
* Update w_topline, w_leftcol and the cursor position.
|
||||||
@@ -9685,10 +9706,10 @@ ex_filetype(exarg_T *eap)
|
|||||||
static void
|
static void
|
||||||
ex_setfiletype(exarg_T *eap)
|
ex_setfiletype(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (!did_filetype)
|
if (did_filetype)
|
||||||
{
|
return;
|
||||||
char_u *arg = eap->arg;
|
|
||||||
|
|
||||||
|
char_u *arg = eap->arg;
|
||||||
if (STRNCMP(arg, "FALLBACK ", 9) == 0)
|
if (STRNCMP(arg, "FALLBACK ", 9) == 0)
|
||||||
arg += 9;
|
arg += 9;
|
||||||
|
|
||||||
@@ -9696,7 +9717,6 @@ ex_setfiletype(exarg_T *eap)
|
|||||||
if (arg != eap->arg)
|
if (arg != eap->arg)
|
||||||
did_filetype = FALSE;
|
did_filetype = FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ex_digraphs(exarg_T *eap UNUSED)
|
ex_digraphs(exarg_T *eap UNUSED)
|
||||||
|
@@ -368,8 +368,9 @@ finish_incsearch_highlighting(
|
|||||||
incsearch_state_T *is_state,
|
incsearch_state_T *is_state,
|
||||||
int call_update_screen)
|
int call_update_screen)
|
||||||
{
|
{
|
||||||
if (is_state->did_incsearch)
|
if (!is_state->did_incsearch)
|
||||||
{
|
return;
|
||||||
|
|
||||||
is_state->did_incsearch = FALSE;
|
is_state->did_incsearch = FALSE;
|
||||||
if (gotesc)
|
if (gotesc)
|
||||||
curwin->w_cursor = is_state->save_cursor;
|
curwin->w_cursor = is_state->save_cursor;
|
||||||
@@ -398,7 +399,6 @@ finish_incsearch_highlighting(
|
|||||||
if (call_update_screen)
|
if (call_update_screen)
|
||||||
update_screen(UPD_SOME_VALID);
|
update_screen(UPD_SOME_VALID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do 'incsearch' highlighting if desired.
|
* Do 'incsearch' highlighting if desired.
|
||||||
@@ -4032,14 +4032,14 @@ escape_fname(char_u **pp)
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
p = alloc(STRLEN(*pp) + 2);
|
p = alloc(STRLEN(*pp) + 2);
|
||||||
if (p != NULL)
|
if (p == NULL)
|
||||||
{
|
return;
|
||||||
|
|
||||||
p[0] = '\\';
|
p[0] = '\\';
|
||||||
STRCPY(p + 1, *pp);
|
STRCPY(p + 1, *pp);
|
||||||
vim_free(*pp);
|
vim_free(*pp);
|
||||||
*pp = p;
|
*pp = p;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For each file name in files[num_files]:
|
* For each file name in files[num_files]:
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1115,
|
||||||
/**/
|
/**/
|
||||||
1114,
|
1114,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user