mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
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:
@@ -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, {
|
||||
@@ -4783,7 +4785,6 @@ void ex_oldfiles(exarg_T *eap)
|
||||
xfree(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ex_trust(exarg_T *eap)
|
||||
|
@@ -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>");
|
||||
@@ -754,7 +757,6 @@ void ex_compiler(exarg_T *eap)
|
||||
do_unlet(S_LEN("g:current_compiler"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ":checktime [buffer]"
|
||||
@@ -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.
|
||||
@@ -887,5 +891,4 @@ void ex_drop(exarg_T *eap)
|
||||
eap->cmdidx = CMD_first;
|
||||
}
|
||||
ex_rewind(eap);
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
@@ -4679,8 +4687,6 @@ static void ex_tabclose(exarg_T *eap)
|
||||
} else if (!text_locked() && !curbuf_locked()) {
|
||||
tabpage_close(eap->forceit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ":tabonly": close all tab pages except the current one
|
||||
@@ -4688,11 +4694,19 @@ 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.
|
||||
@@ -4713,8 +4727,6 @@ static void ex_tabonly(exarg_T *eap)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Close the current tab page.
|
||||
@@ -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 {
|
||||
@@ -4801,7 +4816,6 @@ static void ex_hide(exarg_T *eap)
|
||||
}
|
||||
win_close(win, false, eap->forceit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ":stop" and ":suspend": Suspend Vim.
|
||||
@@ -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;
|
||||
@@ -5428,7 +5444,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;
|
||||
|
||||
@@ -5892,7 +5910,6 @@ static void ex_at(exarg_T *eap)
|
||||
}
|
||||
|
||||
exec_from_reg = save_efr;
|
||||
}
|
||||
}
|
||||
|
||||
/// ":!".
|
||||
@@ -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);
|
||||
@@ -6232,7 +6254,6 @@ static void ex_mark(exarg_T *eap)
|
||||
emsg(_("E191: Argument must be a letter or forward/backward quote"));
|
||||
}
|
||||
curwin->w_cursor = pos; // restore curwin->w_cursor
|
||||
}
|
||||
}
|
||||
|
||||
/// Update w_topline, w_leftcol and the cursor position.
|
||||
@@ -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;
|
||||
}
|
||||
@@ -7157,7 +7180,6 @@ static void ex_setfiletype(exarg_T *eap)
|
||||
if (arg != eap->arg) {
|
||||
did_filetype = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ex_digraphs(exarg_T *eap)
|
||||
|
@@ -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;
|
||||
@@ -601,7 +604,6 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
|
||||
if (call_update_screen) {
|
||||
update_screen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize the current command-line info.
|
||||
|
Reference in New Issue
Block a user