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:
zeertzjq
2022-12-31 06:41:23 +08:00
committed by GitHub
parent 6a45360de9
commit 99cf111289
4 changed files with 291 additions and 263 deletions

View File

@@ -705,54 +705,56 @@ 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
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>");
} else {
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>");
} else {
// ":compiler! {name}" sets local options.
// To remain backwards compatible "current_compiler" is always
// used. A user's compiler plugin may set it, the distributed
// plugin will then skip the settings. Afterwards set
// "b:current_compiler" and restore "current_compiler".
// Explicitly prepend "g:" to make it work in a function.
old_cur_comp = (char *)get_var_value("g:current_compiler");
if (old_cur_comp != NULL) {
old_cur_comp = xstrdup(old_cur_comp);
}
do_cmdline_cmd("command -nargs=* -keepscript CompilerSet setlocal <args>");
// ":compiler! {name}" sets local options.
// To remain backwards compatible "current_compiler" is always
// used. A user's compiler plugin may set it, the distributed
// plugin will then skip the settings. Afterwards set
// "b:current_compiler" and restore "current_compiler".
// Explicitly prepend "g:" to make it work in a function.
old_cur_comp = (char *)get_var_value("g:current_compiler");
if (old_cur_comp != NULL) {
old_cur_comp = xstrdup(old_cur_comp);
}
do_unlet(S_LEN("g:current_compiler"), true);
do_unlet(S_LEN("b:current_compiler"), true);
do_cmdline_cmd("command -nargs=* -keepscript CompilerSet setlocal <args>");
}
do_unlet(S_LEN("g:current_compiler"), true);
do_unlet(S_LEN("b:current_compiler"), true);
snprintf(buf, bufsize, "compiler/%s.vim", eap->arg);
snprintf(buf, bufsize, "compiler/%s.vim", eap->arg);
if (source_runtime(buf, DIP_ALL) == FAIL) {
// Try lua compiler
snprintf(buf, bufsize, "compiler/%s.lua", eap->arg);
if (source_runtime(buf, DIP_ALL) == FAIL) {
// Try lua compiler
snprintf(buf, bufsize, "compiler/%s.lua", eap->arg);
if (source_runtime(buf, DIP_ALL) == FAIL) {
semsg(_("E666: compiler not supported: %s"), eap->arg);
}
semsg(_("E666: compiler not supported: %s"), eap->arg);
}
xfree(buf);
}
xfree(buf);
do_cmdline_cmd(":delcommand CompilerSet");
do_cmdline_cmd(":delcommand CompilerSet");
// Set "b:current_compiler" from "current_compiler".
p = (char *)get_var_value("g:current_compiler");
if (p != NULL) {
set_internal_string_var("b:current_compiler", p);
}
// Set "b:current_compiler" from "current_compiler".
p = (char *)get_var_value("g:current_compiler");
if (p != NULL) {
set_internal_string_var("b:current_compiler", p);
}
// Restore "current_compiler" for ":compiler {name}".
if (!eap->forceit) {
if (old_cur_comp != NULL) {
set_internal_string_var("g:current_compiler", old_cur_comp);
xfree(old_cur_comp);
} else {
do_unlet(S_LEN("g:current_compiler"), true);
}
// Restore "current_compiler" for ":compiler {name}".
if (!eap->forceit) {
if (old_cur_comp != NULL) {
set_internal_string_var("g:current_compiler", old_cur_comp);
xfree(old_cur_comp);
} else {
do_unlet(S_LEN("g:current_compiler"), true);
}
}
}
@@ -847,45 +849,46 @@ 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 {
// ":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.
buf = buflist_findnr(ARGLIST[0].ae_fnum);
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_buffer == buf) {
goto_tabpage_win(tp, wp);
curwin->w_arg_idx = 0;
if (!bufIsChanged(curbuf)) {
const int save_ar = curbuf->b_p_ar;
// reload the file if it is newer
curbuf->b_p_ar = 1;
buf_check_timestamp(curbuf);
curbuf->b_p_ar = save_ar;
}
return;
}
}
// Check whether the current buffer is changed. If so, we will need
// to split the current window or data could be lost.
// Skip the check if the 'hidden' option is set, as in this case the
// buffer won't be lost.
if (!buf_hide(curbuf)) {
emsg_off++;
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
emsg_off--;
}
// Fake a ":sfirst" or ":first" command edit the first argument.
if (split) {
eap->cmdidx = CMD_sfirst;
eap->cmd[0] = 's';
} else {
eap->cmdidx = CMD_first;
}
ex_rewind(eap);
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.
buf = buflist_findnr(ARGLIST[0].ae_fnum);
FOR_ALL_TAB_WINDOWS(tp, wp) {
if (wp->w_buffer == buf) {
goto_tabpage_win(tp, wp);
curwin->w_arg_idx = 0;
if (!bufIsChanged(curbuf)) {
const int save_ar = curbuf->b_p_ar;
// reload the file if it is newer
curbuf->b_p_ar = 1;
buf_check_timestamp(curbuf);
curbuf->b_p_ar = save_ar;
}
return;
}
}
// Check whether the current buffer is changed. If so, we will need
// to split the current window or data could be lost.
// Skip the check if the 'hidden' option is set, as in this case the
// buffer won't be lost.
if (!buf_hide(curbuf)) {
emsg_off++;
split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
emsg_off--;
}
// Fake a ":sfirst" or ":first" command edit the first argument.
if (split) {
eap->cmdidx = CMD_sfirst;
eap->cmd[0] = 's';
} else {
eap->cmdidx = CMD_first;
}
ex_rewind(eap);
}