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) {
|
if (l == NULL) {
|
||||||
msg(_("No old files"));
|
msg(_("No old files"));
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
msg_start();
|
msg_start();
|
||||||
msg_scroll = true;
|
msg_scroll = true;
|
||||||
TV_LIST_ITER(l, li, {
|
TV_LIST_ITER(l, li, {
|
||||||
@@ -4784,7 +4786,6 @@ void ex_oldfiles(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ex_trust(exarg_T *eap)
|
void ex_trust(exarg_T *eap)
|
||||||
{
|
{
|
||||||
|
@@ -705,9 +705,12 @@ void ex_compiler(exarg_T *eap)
|
|||||||
// List all compiler scripts.
|
// List all compiler scripts.
|
||||||
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT
|
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT
|
||||||
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT
|
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
size_t bufsize = strlen(eap->arg) + 14;
|
size_t bufsize = strlen(eap->arg) + 14;
|
||||||
buf = xmalloc(bufsize);
|
buf = xmalloc(bufsize);
|
||||||
|
|
||||||
if (eap->forceit) {
|
if (eap->forceit) {
|
||||||
// ":compiler! {name}" sets global options
|
// ":compiler! {name}" sets global options
|
||||||
do_cmdline_cmd("command -nargs=* CompilerSet set <args>");
|
do_cmdline_cmd("command -nargs=* CompilerSet set <args>");
|
||||||
@@ -755,7 +758,6 @@ void ex_compiler(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// ":checktime [buffer]"
|
/// ":checktime [buffer]"
|
||||||
void ex_checktime(exarg_T *eap)
|
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
|
// 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);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ":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.
|
||||||
@@ -888,4 +892,3 @@ void ex_drop(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
ex_rewind(eap);
|
ex_rewind(eap);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@@ -4663,11 +4663,19 @@ static void ex_tabclose(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
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(_("E784: Cannot close last tab page"));
|
emsg(_("E784: Cannot close last tab page"));
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int tab_number = get_tabpage_arg(eap);
|
int tab_number = get_tabpage_arg(eap);
|
||||||
if (eap->errmsg == NULL) {
|
if (eap->errmsg != NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tabpage_T *tp = find_tabpage(tab_number);
|
tabpage_T *tp = find_tabpage(tab_number);
|
||||||
if (tp == NULL) {
|
if (tp == NULL) {
|
||||||
beep_flush();
|
beep_flush();
|
||||||
@@ -4680,19 +4688,25 @@ static void ex_tabclose(exarg_T *eap)
|
|||||||
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
|
||||||
static void ex_tabonly(exarg_T *eap)
|
static void ex_tabonly(exarg_T *eap)
|
||||||
{
|
{
|
||||||
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 {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int tab_number = get_tabpage_arg(eap);
|
int 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.
|
||||||
@@ -4714,8 +4728,6 @@ static void ex_tabonly(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Close the current tab page.
|
/// Close the current tab page.
|
||||||
void tabpage_close(int forceit)
|
void tabpage_close(int forceit)
|
||||||
@@ -4782,7 +4794,10 @@ static void ex_only(exarg_T *eap)
|
|||||||
static void ex_hide(exarg_T *eap)
|
static void ex_hide(exarg_T *eap)
|
||||||
{
|
{
|
||||||
// ":hide" or ":hide | cmd": hide current window
|
// ":hide" or ":hide | cmd": hide current window
|
||||||
if (!eap->skip) {
|
if (eap->skip) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (eap->addr_count == 0) {
|
if (eap->addr_count == 0) {
|
||||||
win_close(curwin, false, eap->forceit); // don't free buffer
|
win_close(curwin, false, eap->forceit); // don't free buffer
|
||||||
} else {
|
} else {
|
||||||
@@ -4802,7 +4817,6 @@ static void ex_hide(exarg_T *eap)
|
|||||||
win_close(win, false, eap->forceit);
|
win_close(win, false, eap->forceit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// ":stop" and ":suspend": Suspend Vim.
|
/// ":stop" and ":suspend": Suspend Vim.
|
||||||
static void ex_stop(exarg_T *eap)
|
static void ex_stop(exarg_T *eap)
|
||||||
@@ -5384,12 +5398,14 @@ static void ex_read(exarg_T *eap)
|
|||||||
|
|
||||||
if (eap->usefilter) { // :r!cmd
|
if (eap->usefilter) { // :r!cmd
|
||||||
do_bang(1, eap, false, false, true);
|
do_bang(1, eap, false, false, true);
|
||||||
} else {
|
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;
|
||||||
}
|
}
|
||||||
int i;
|
|
||||||
|
|
||||||
|
int i;
|
||||||
if (*eap->arg == NUL) {
|
if (*eap->arg == NUL) {
|
||||||
if (check_fname() == FAIL) { // check for no file name
|
if (check_fname() == FAIL) { // check for no file name
|
||||||
return;
|
return;
|
||||||
@@ -5429,7 +5445,6 @@ static void ex_read(exarg_T *eap)
|
|||||||
redraw_curbuf_later(UPD_VALID);
|
redraw_curbuf_later(UPD_VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static char *prev_dir = NULL;
|
static char *prev_dir = NULL;
|
||||||
|
|
||||||
@@ -5584,6 +5599,7 @@ void ex_cd(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CdScope scope = kCdScopeGlobal;
|
CdScope scope = kCdScopeGlobal;
|
||||||
switch (eap->cmdidx) {
|
switch (eap->cmdidx) {
|
||||||
case CMD_tcd:
|
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.
|
// 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) {
|
if (do_execreg(c, true, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, true) == FAIL) {
|
||||||
beep_flush();
|
beep_flush();
|
||||||
} else {
|
return;
|
||||||
bool save_efr = exec_from_reg;
|
}
|
||||||
|
|
||||||
|
const bool save_efr = exec_from_reg;
|
||||||
|
|
||||||
exec_from_reg = true;
|
exec_from_reg = true;
|
||||||
|
|
||||||
@@ -5893,7 +5911,6 @@ static void ex_at(exarg_T *eap)
|
|||||||
|
|
||||||
exec_from_reg = save_efr;
|
exec_from_reg = save_efr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// ":!".
|
/// ":!".
|
||||||
static void ex_bang(exarg_T *eap)
|
static void ex_bang(exarg_T *eap)
|
||||||
@@ -6222,9 +6239,14 @@ static void ex_mark(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
if (*eap->arg == NUL) { // No argument?
|
if (*eap->arg == NUL) { // No argument?
|
||||||
emsg(_(e_argreq));
|
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);
|
semsg(_(e_trailing_arg), eap->arg);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pos_T pos = curwin->w_cursor; // save curwin->w_cursor
|
pos_T 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);
|
||||||
@@ -6233,7 +6255,6 @@ static void ex_mark(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
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.
|
||||||
void update_topline_cursor(void)
|
void update_topline_cursor(void)
|
||||||
@@ -7146,9 +7167,11 @@ void filetype_maybe_enable(void)
|
|||||||
/// ":setfiletype [FALLBACK] {name}"
|
/// ":setfiletype [FALLBACK] {name}"
|
||||||
static void ex_setfiletype(exarg_T *eap)
|
static void ex_setfiletype(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (!did_filetype) {
|
if (did_filetype) {
|
||||||
char *arg = eap->arg;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *arg = eap->arg;
|
||||||
if (strncmp(arg, "FALLBACK ", 9) == 0) {
|
if (strncmp(arg, "FALLBACK ", 9) == 0) {
|
||||||
arg += 9;
|
arg += 9;
|
||||||
}
|
}
|
||||||
@@ -7158,7 +7181,6 @@ static void ex_setfiletype(exarg_T *eap)
|
|||||||
did_filetype = false;
|
did_filetype = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void ex_digraphs(exarg_T *eap)
|
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)
|
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;
|
s->did_incsearch = false;
|
||||||
if (gotesc) {
|
if (gotesc) {
|
||||||
curwin->w_cursor = s->save_cursor;
|
curwin->w_cursor = s->save_cursor;
|
||||||
@@ -602,7 +605,6 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
|
|||||||
update_screen();
|
update_screen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize the current command-line info.
|
/// Initialize the current command-line info.
|
||||||
static void init_ccline(int firstc, int indent)
|
static void init_ccline(int firstc, int indent)
|
||||||
|
Reference in New Issue
Block a user