summaryrefslogtreecommitdiffstats
path: root/src/change.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-10-16 21:43:07 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-16 21:43:07 +0100
commit3f0092c141824356b55b11cd3985baaf4df65334 (patch)
tree23f7c7a3bd22311c685562c94799958bc03ef0aa /src/change.c
parent9d8620b519a84983bc8c24cb6c302f4d6b55a6c0 (diff)
patch 9.0.0777: code is indented too muchv9.0.0777
Problem: Code is indented too much. Solution: Use an early return. (Yegappan Lakshmanan, closes #11386)
Diffstat (limited to 'src/change.c')
-rw-r--r--src/change.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/change.c b/src/change.c
index f036a3767c..bb54edf6d0 100644
--- a/src/change.c
+++ b/src/change.c
@@ -28,43 +28,43 @@ change_warning(int col)
{
static char *w_readonly = N_("W10: Warning: Changing a readonly file");
- if (curbuf->b_did_warn == FALSE
- && curbufIsChanged() == 0
- && !autocmd_busy
- && curbuf->b_p_ro)
- {
- ++curbuf_lock;
- apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
- --curbuf_lock;
- if (!curbuf->b_p_ro)
- return;
+ if (curbuf->b_did_warn
+ || curbufIsChanged()
+ || autocmd_busy
+ || !curbuf->b_p_ro)
+ return;
+
+ ++curbuf_lock;
+ apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
+ --curbuf_lock;
+ if (!curbuf->b_p_ro)
+ return;
- // Do what msg() does, but with a column offset if the warning should
- // be after the mode message.
- msg_start();
- if (msg_row == Rows - 1)
- msg_col = col;
- msg_source(HL_ATTR(HLF_W));
- msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
+ // Do what msg() does, but with a column offset if the warning should
+ // be after the mode message.
+ msg_start();
+ if (msg_row == Rows - 1)
+ msg_col = col;
+ msg_source(HL_ATTR(HLF_W));
+ msg_puts_attr(_(w_readonly), HL_ATTR(HLF_W) | MSG_HIST);
#ifdef FEAT_EVAL
- set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
+ set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
#endif
- msg_clr_eos();
- (void)msg_end();
- if (msg_silent == 0 && !silent_mode
+ msg_clr_eos();
+ (void)msg_end();
+ if (msg_silent == 0 && !silent_mode
#ifdef FEAT_EVAL
- && time_for_testing != 1
+ && time_for_testing != 1
#endif
- )
- {
- out_flush();
- ui_delay(1002L, TRUE); // give the user time to think about it
- }
- curbuf->b_did_warn = TRUE;
- redraw_cmdline = FALSE; // don't redraw and erase the message
- if (msg_row < Rows - 1)
- showmode();
+ )
+ {
+ out_flush();
+ ui_delay(1002L, TRUE); // give the user time to think about it
}
+ curbuf->b_did_warn = TRUE;
+ redraw_cmdline = FALSE; // don't redraw and erase the message
+ if (msg_row < Rows - 1)
+ showmode();
}
/*
@@ -159,25 +159,25 @@ check_recorded_changes(
linenr_T lnume,
long xtra)
{
- if (buf->b_recorded_changes != NULL && xtra != 0)
- {
- listitem_T *li;
- linenr_T prev_lnum;
- linenr_T prev_lnume;
+ if (buf->b_recorded_changes == NULL || xtra == 0)
+ return;
+
+ listitem_T *li;
+ linenr_T prev_lnum;
+ linenr_T prev_lnume;
- FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
+ FOR_ALL_LIST_ITEMS(buf->b_recorded_changes, li)
+ {
+ prev_lnum = (linenr_T)dict_get_number(
+ li->li_tv.vval.v_dict, "lnum");
+ prev_lnume = (linenr_T)dict_get_number(
+ li->li_tv.vval.v_dict, "end");
+ if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
{
- prev_lnum = (linenr_T)dict_get_number(
- li->li_tv.vval.v_dict, "lnum");
- prev_lnume = (linenr_T)dict_get_number(
- li->li_tv.vval.v_dict, "end");
- if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
- {
- // the current change is going to make the line number in
- // the older change invalid, flush now
- invoke_listeners(curbuf);
- break;
- }
+ // the current change is going to make the line number in
+ // the older change invalid, flush now
+ invoke_listeners(curbuf);
+ break;
}
}
}