diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-14 21:36:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-14 21:36:15 +0800 |
commit | 2065ce877ef81bcd66132bd26e75aa4d761dca12 (patch) | |
tree | 875ab83390eb34fc6d85b5b43c35600166eac56d /src/nvim/ui.c | |
parent | d549734fb4792bcdb5395006538f7c6d856252e7 (diff) | |
download | rneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.tar.gz rneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.tar.bz2 rneovim-2065ce877ef81bcd66132bd26e75aa4d761dca12.zip |
vim-patch:partial:9.0.1196: code is indented more than necessary (#21796)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11813)
https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8
Partial port as this depends on some previous eval and 'smoothscroll'
patches.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 7775d98983..b25fa04c8b 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -292,34 +292,36 @@ void vim_beep(unsigned val) { called_vim_beep = true; - if (emsg_silent == 0 && !in_assert_fails) { - if (!((bo_flags & val) || (bo_flags & BO_ALL))) { - static int beeps = 0; - static uint64_t start_time = 0; - - // Only beep up to three times per half a second, - // otherwise a sequence of beeps would freeze Vim. - if (start_time == 0 || os_hrtime() - start_time > 500000000U) { - beeps = 0; - start_time = os_hrtime(); - } - beeps++; - if (beeps <= 3) { - if (p_vb) { - ui_call_visual_bell(); - } else { - ui_call_bell(); - } + if (emsg_silent != 0 || in_assert_fails) { + return; + } + + if (!((bo_flags & val) || (bo_flags & BO_ALL))) { + static int beeps = 0; + static uint64_t start_time = 0; + + // Only beep up to three times per half a second, + // otherwise a sequence of beeps would freeze Vim. + if (start_time == 0 || os_hrtime() - start_time > 500000000U) { + beeps = 0; + start_time = os_hrtime(); + } + beeps++; + if (beeps <= 3) { + if (p_vb) { + ui_call_visual_bell(); + } else { + ui_call_bell(); } } + } - // When 'debug' contains "beep" produce a message. If we are sourcing - // a script or executing a function give the user a hint where the beep - // comes from. - if (vim_strchr(p_debug, 'e') != NULL) { - msg_source(HL_ATTR(HLF_W)); - msg_attr(_("Beep!"), HL_ATTR(HLF_W)); - } + // When 'debug' contains "beep" produce a message. If we are sourcing + // a script or executing a function give the user a hint where the beep + // comes from. + if (vim_strchr(p_debug, 'e') != NULL) { + msg_source(HL_ATTR(HLF_W)); + msg_attr(_("Beep!"), HL_ATTR(HLF_W)); } } |