aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-04-13 00:37:27 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-05-25 05:27:17 -0400
commit138110e082e95ff82f042591c476b7479ba436e0 (patch)
tree35a40f8c68c0185c62d274e3e6ca4bf4f0e108ff /src
parent4769deb36a54c3b2a4a2d2addb2937c1aa7dd629 (diff)
downloadrneovim-138110e082e95ff82f042591c476b7479ba436e0.tar.gz
rneovim-138110e082e95ff82f042591c476b7479ba436e0.tar.bz2
rneovim-138110e082e95ff82f042591c476b7479ba436e0.zip
vim-patch:8.0.0683: visual bell flashes too quickly
Problem: When using a visual bell there is no delay, causing the flash to be very short, possibly unnoticeable. Also, the flash and the beep can lockup the UI when repeated often. Solution: Do the delay in Vim or flush the output before the delay. Limit the bell to once per half a second. (Ozaki Kiichi, closes vim/vim#1789) https://github.com/vim/vim/commit/2e147caa14f622dfd1c1def8e07c113b9b85d4b2
Diffstat (limited to 'src')
-rw-r--r--src/nvim/misc1.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 0008409731..4fc2451788 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -2583,10 +2583,17 @@ 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 uint64_t start_time = 0;
+
+ // Only beep once per half a second, otherwise a sequence of beeps
+ // would freeze Vim.
+ if (start_time == 0 || os_hrtime() - start_time > 500000000u) {
+ start_time = os_hrtime();
+ if (p_vb) {
+ ui_call_visual_bell();
+ } else {
+ ui_call_bell();
+ }
}
}