vim-patch:9.0.1105: code is indented too much (#27314)

Problem:    Code is indented too much.
Solution:   Use an early return. (Yegappan Lakshmanan, closes vim/vim#11756)

87c1cbbe98

Omit free_eval_tofree_later(): Vim9 script only.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2024-02-03 09:42:04 +08:00
committed by GitHub
parent be1d09c427
commit 1f40b4e222
3 changed files with 178 additions and 150 deletions

View File

@@ -1439,7 +1439,10 @@ static int pc_col;
void edit_putchar(int c, bool highlight) void edit_putchar(int c, bool highlight)
{ {
if (curwin->w_grid_alloc.chars != NULL || default_grid.chars != NULL) { if (curwin->w_grid_alloc.chars == NULL && default_grid.chars == NULL) {
return;
}
int attr; int attr;
update_topline(curwin); // just in case w_topline isn't valid update_topline(curwin); // just in case w_topline isn't valid
validate_cursor(); validate_cursor();
@@ -1477,7 +1480,6 @@ void edit_putchar(int c, bool highlight)
char buf[MB_MAXCHAR + 1]; char buf[MB_MAXCHAR + 1];
grid_line_puts(pc_col, buf, utf_char2bytes(c, buf), attr); grid_line_puts(pc_col, buf, utf_char2bytes(c, buf), attr);
grid_line_flush(); grid_line_flush();
}
} }
/// @return the effective prompt for the specified buffer. /// @return the effective prompt for the specified buffer.
@@ -1591,10 +1593,12 @@ void display_dollar(colnr_T col_arg)
// in insert mode. // in insert mode.
void undisplay_dollar(void) void undisplay_dollar(void)
{ {
if (dollar_vcol >= 0) { if (dollar_vcol < 0) {
return;
}
dollar_vcol = -1; dollar_vcol = -1;
redrawWinline(curwin, curwin->w_cursor.lnum); redrawWinline(curwin, curwin->w_cursor.lnum);
}
} }
/// Insert an indent (for <Tab> or CTRL-T) or delete an indent (for CTRL-D). /// Insert an indent (for <Tab> or CTRL-T) or delete an indent (for CTRL-D).

View File

@@ -758,12 +758,15 @@ void eval_patch(const char *const origfile, const char *const difffile, const ch
void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, bool skip) void fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, bool skip)
{ {
*evalarg = (evalarg_T){ .eval_flags = skip ? 0 : EVAL_EVALUATE }; *evalarg = (evalarg_T){ .eval_flags = skip ? 0 : EVAL_EVALUATE };
if (eap != NULL) {
if (eap == NULL) {
return;
}
if (getline_equal(eap->getline, eap->cookie, getsourceline)) { if (getline_equal(eap->getline, eap->cookie, getsourceline)) {
evalarg->eval_getline = eap->getline; evalarg->eval_getline = eap->getline;
evalarg->eval_cookie = eap->cookie; evalarg->eval_cookie = eap->cookie;
} }
}
} }
/// Top level evaluation function, returning a boolean. /// Top level evaluation function, returning a boolean.
@@ -2326,7 +2329,10 @@ static int eval_func(char **const arg, evalarg_T *const evalarg, char *const nam
/// After using "evalarg" filled from "eap": free the memory. /// After using "evalarg" filled from "eap": free the memory.
void clear_evalarg(evalarg_T *evalarg, exarg_T *eap) void clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
{ {
if (evalarg != NULL) { if (evalarg == NULL) {
return;
}
if (evalarg->eval_tofree != NULL) { if (evalarg->eval_tofree != NULL) {
if (eap != NULL) { if (eap != NULL) {
// We may need to keep the original command line, e.g. for // We may need to keep the original command line, e.g. for
@@ -2340,7 +2346,6 @@ void clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
} }
evalarg->eval_tofree = NULL; evalarg->eval_tofree = NULL;
} }
}
} }
/// The "evaluate" argument: When false, the argument is only parsed but not /// The "evaluate" argument: When false, the argument is only parsed but not
@@ -3626,12 +3631,14 @@ static int check_can_index(typval_T *rettv, bool evaluate, bool verbose)
/// slice() function /// slice() function
void f_slice(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) void f_slice(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{ {
if (check_can_index(argvars, true, false) == OK) { if (check_can_index(argvars, true, false) != OK) {
return;
}
tv_copy(argvars, rettv); tv_copy(argvars, rettv);
eval_index_inner(rettv, true, argvars + 1, eval_index_inner(rettv, true, argvars + 1,
argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2, argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
true, NULL, 0, false); true, NULL, 0, false);
}
} }
/// Apply index or range to "rettv". /// Apply index or range to "rettv".
@@ -4248,7 +4255,11 @@ static void partial_free(partial_T *pt)
/// becomes zero. /// becomes zero.
void partial_unref(partial_T *pt) void partial_unref(partial_T *pt)
{ {
if (pt != NULL && --pt->pt_refcount <= 0) { if (pt == NULL) {
return;
}
if (--pt->pt_refcount <= 0) {
partial_free(pt); partial_free(pt);
} }
} }
@@ -8241,9 +8252,13 @@ void last_set_msg(sctx_T script_ctx)
/// Should only be invoked when 'verbose' is non-zero. /// Should only be invoked when 'verbose' is non-zero.
void option_last_set_msg(LastSet last_set) void option_last_set_msg(LastSet last_set)
{ {
if (last_set.script_ctx.sc_sid != 0) { if (last_set.script_ctx.sc_sid == 0) {
return;
}
bool should_free; bool should_free;
char *p = get_scriptname(last_set, &should_free); char *p = get_scriptname(last_set, &should_free);
verbose_enter(); verbose_enter();
msg_puts(_("\n\tLast set from ")); msg_puts(_("\n\tLast set from "));
msg_puts(p); msg_puts(p);
@@ -8255,7 +8270,6 @@ void option_last_set_msg(LastSet last_set)
xfree(p); xfree(p);
} }
verbose_leave(); verbose_leave();
}
} }
// reset v:option_new, v:option_old, v:option_oldlocal, v:option_oldglobal, // reset v:option_new, v:option_old, v:option_oldlocal, v:option_oldglobal,

View File

@@ -1937,7 +1937,11 @@ static void extend_list(typval_T *argvars, const char *arg_errmsg, bool is_new,
list_T *l1 = argvars[0].vval.v_list; list_T *l1 = argvars[0].vval.v_list;
list_T *const l2 = argvars[1].vval.v_list; list_T *const l2 = argvars[1].vval.v_list;
if (is_new || !value_check_lock(tv_list_locked(l1), arg_errmsg, TV_TRANSLATE)) {
if (!is_new && value_check_lock(tv_list_locked(l1), arg_errmsg, TV_TRANSLATE)) {
return;
}
if (is_new) { if (is_new) {
l1 = tv_list_copy(NULL, l1, false, get_copyID()); l1 = tv_list_copy(NULL, l1, false, get_copyID());
if (l1 == NULL) { if (l1 == NULL) {
@@ -1975,7 +1979,6 @@ static void extend_list(typval_T *argvars, const char *arg_errmsg, bool is_new,
} else { } else {
tv_copy(&argvars[0], rettv); tv_copy(&argvars[0], rettv);
} }
}
} }
/// extend() a Dict. Append Dict argvars[1] to Dict argvars[0] and return the /// extend() a Dict. Append Dict argvars[1] to Dict argvars[0] and return the
@@ -1985,15 +1988,23 @@ static void extend_list(typval_T *argvars, const char *arg_errmsg, bool is_new,
static void extend_dict(typval_T *argvars, const char *arg_errmsg, bool is_new, typval_T *rettv) static void extend_dict(typval_T *argvars, const char *arg_errmsg, bool is_new, typval_T *rettv)
{ {
dict_T *d1 = argvars[0].vval.v_dict; dict_T *d1 = argvars[0].vval.v_dict;
dict_T *const d2 = argvars[1].vval.v_dict;
if (d1 == NULL) { if (d1 == NULL) {
const bool locked = value_check_lock(VAR_FIXED, arg_errmsg, TV_TRANSLATE); const bool locked = value_check_lock(VAR_FIXED, arg_errmsg, TV_TRANSLATE);
(void)locked; (void)locked;
assert(locked == true); assert(locked == true);
} else if (d2 == NULL) { return;
}
dict_T *const d2 = argvars[1].vval.v_dict;
if (d2 == NULL) {
// Do nothing // Do nothing
tv_copy(&argvars[0], rettv); tv_copy(&argvars[0], rettv);
} else if (is_new || !value_check_lock(d1->dv_lock, arg_errmsg, TV_TRANSLATE)) { return;
}
if (!is_new && value_check_lock(d1->dv_lock, arg_errmsg, TV_TRANSLATE)) {
return;
}
if (is_new) { if (is_new) {
d1 = tv_dict_copy(NULL, d1, false, get_copyID()); d1 = tv_dict_copy(NULL, d1, false, get_copyID());
if (d1 == NULL) { if (d1 == NULL) {
@@ -2033,7 +2044,6 @@ static void extend_dict(typval_T *argvars, const char *arg_errmsg, bool is_new,
} else { } else {
tv_copy(&argvars[0], rettv); tv_copy(&argvars[0], rettv);
} }
}
} }
/// "extend()" or "extendnew()" function. /// "extend()" or "extendnew()" function.