diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-26 18:44:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-26 18:44:35 +0200 |
commit | fc7861f0faf907fba4cd0259bc3e8665f3df473b (patch) | |
tree | 62775e9ea30a3a2f0cf869f6a787894d1d3103d6 | |
parent | aabda31d5491398783ba70b2e24c58e68454db28 (diff) | |
parent | 5e048baa5fd5c0d38448d9b0e3511c247ad47ec7 (diff) | |
download | rneovim-fc7861f0faf907fba4cd0259bc3e8665f3df473b.tar.gz rneovim-fc7861f0faf907fba4cd0259bc3e8665f3df473b.tar.bz2 rneovim-fc7861f0faf907fba4cd0259bc3e8665f3df473b.zip |
Merge #9897 from janlazo/vim-8.0.0683
-rw-r--r-- | src/nvim/misc1.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index ee870b7224..4ef0103c4f 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2583,10 +2583,22 @@ void vim_beep(unsigned val) if (emsg_silent == 0) { if (!((bo_flags & val) || (bo_flags & BO_ALL))) { - if (p_vb) { - ui_call_visual_bell(); - } else { - ui_call_bell(); + 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(); + } } } |