0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 9.0.1132: code is indented more than needed

Problem:    Code is indented more than needed.
Solution:   Use an early return to reduce indentation. (Yegappan Lakshmanan,
            closes #11769)
This commit is contained in:
Yegappan Lakshmanan
2023-01-02 16:54:53 +00:00
committed by Bram Moolenaar
parent a2942c7468
commit dc4daa3a39
13 changed files with 647 additions and 642 deletions

View File

@@ -718,66 +718,66 @@ f_win_execute(typval_T *argvars, typval_T *rettv)
id = (int)tv_get_number(argvars);
wp = win_id2wp_tp(id, &tp);
if (wp != NULL && tp != NULL)
if (wp == NULL || tp == NULL)
return;
pos_T curpos = wp->w_cursor;
char_u cwd[MAXPATHL];
int cwd_status = FAIL;
#ifdef FEAT_AUTOCHDIR
char_u autocwd[MAXPATHL];
int apply_acd = FALSE;
#endif
// Getting and setting directory can be slow on some systems, only do
// this when the current or target window/tab have a local directory or
// 'acd' is set.
if (curwin != wp
&& (curwin->w_localdir != NULL
|| wp->w_localdir != NULL
|| (curtab != tp
&& (curtab->tp_localdir != NULL
|| tp->tp_localdir != NULL))
#ifdef FEAT_AUTOCHDIR
|| p_acd
#endif
))
cwd_status = mch_dirname(cwd, MAXPATHL);
#ifdef FEAT_AUTOCHDIR
// If 'acd' is set, check we are using that directory. If yes, then
// apply 'acd' afterwards, otherwise restore the current directory.
if (cwd_status == OK && p_acd)
{
pos_T curpos = wp->w_cursor;
char_u cwd[MAXPATHL];
int cwd_status = FAIL;
#ifdef FEAT_AUTOCHDIR
char_u autocwd[MAXPATHL];
int apply_acd = FALSE;
do_autochdir();
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
&& STRCMP(cwd, autocwd) == 0;
}
#endif
// Getting and setting directory can be slow on some systems, only do
// this when the current or target window/tab have a local directory or
// 'acd' is set.
if (curwin != wp
&& (curwin->w_localdir != NULL
|| wp->w_localdir != NULL
|| (curtab != tp
&& (curtab->tp_localdir != NULL
|| tp->tp_localdir != NULL))
if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
{
check_cursor();
execute_common(argvars, rettv, 1);
}
restore_win_noblock(&switchwin, TRUE);
#ifdef FEAT_AUTOCHDIR
|| p_acd
if (apply_acd)
do_autochdir();
else
#endif
))
cwd_status = mch_dirname(cwd, MAXPATHL);
#ifdef FEAT_AUTOCHDIR
// If 'acd' is set, check we are using that directory. If yes, then
// apply 'acd' afterwards, otherwise restore the current directory.
if (cwd_status == OK && p_acd)
{
do_autochdir();
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
&& STRCMP(cwd, autocwd) == 0;
}
#endif
if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
{
check_cursor();
execute_common(argvars, rettv, 1);
}
restore_win_noblock(&switchwin, TRUE);
#ifdef FEAT_AUTOCHDIR
if (apply_acd)
do_autochdir();
else
#endif
if (cwd_status == OK)
if (cwd_status == OK)
mch_chdir((char *)cwd);
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
wp->w_redr_status = TRUE;
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
wp->w_redr_status = TRUE;
// In case the command moved the cursor or changed the Visual area,
// check it is valid.
check_cursor();
if (VIsual_active)
check_pos(curbuf, &VIsual);
}
// In case the command moved the cursor or changed the Visual area,
// check it is valid.
check_cursor();
if (VIsual_active)
check_pos(curbuf, &VIsual);
}
/*
@@ -1093,11 +1093,11 @@ f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv)
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
rettv->vval.v_string = alloc(2);
if (rettv->vval.v_string != NULL)
{
rettv->vval.v_string[0] = cmdwin_type;
rettv->vval.v_string[1] = NUL;
}
if (rettv->vval.v_string == NULL)
return;
rettv->vval.v_string[0] = cmdwin_type;
rettv->vval.v_string[1] = NUL;
}
/*