Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualbell not working #20234

Closed
ambadyanands opened this issue Sep 17, 2022 · 3 comments · Fixed by #20238
Closed

Visualbell not working #20234

ambadyanands opened this issue Sep 17, 2022 · 3 comments · Fixed by #20238
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md tui
Milestone

Comments

@ambadyanands
Copy link

Neovim version (nvim -v)

0.7.2

Vim (not Nvim) behaves the same?

no, vim 9.0

Operating system/version

Arch Linux

Terminal name/version

kitty 0.26.2

$TERM environment variable

xterm-kitty

Installation

Arch official repository (community)

How to reproduce the issue

nvim --clean
:set belloff=""
:set visualbell
Press <Esc> a couple of times from normal mode.

Expected behavior

The screen will flash.

Actual behavior

No UI change. Also tried :set errorbells, no change.

@ambadyanands ambadyanands added the bug issues reporting wrong behavior label Sep 17, 2022
@clason clason added the tui label Sep 17, 2022
@zeertzjq
Copy link
Member

zeertzjq commented Sep 17, 2022

I tried the following in kitty. It is strange that tput flash flashes the screen, but printf '\x1b[?5h\x1b[?5l' doesn't, despite outputing exactly the same bytes.

@zeertzjq
Copy link
Member

zeertzjq commented Sep 17, 2022

Oh, there needs to be a delay between \x1b[?5h and \x1b[?5l, but Nvim always passes NULL as pad to unibi_format(), so padding instructions are always ignored.

@clason clason changed the title visualbell option not working Visualbell not working Sep 17, 2022
@zeertzjq
Copy link
Member

Minimum patch to make this work:

diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 73f47f2b7..664b904d9 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1616,7 +1616,7 @@ static void unibi_goto(UI *ui, int row, int col)
       memset(&vars, 0, sizeof(vars)); \
       data->cork = true; \
 retry: \
-      unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \
+      unibi_format(vars, vars + 26, str, data->params, out, ui, pad, ui); \
       if (data->overflow) { \
         data->bufpos = orig_pos; \
         flush_buf(ui); \
@@ -1658,6 +1658,12 @@ static void out(void *ctx, const char *str, size_t len)
   data->bufpos += len;
 }
 
+static void pad(void *ctx, size_t delay, int scale, int force)
+{
+  flush_buf(ctx);
+  uv_sleep((unsigned)(delay / 10));
+}
+
 static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, const char *val)
 {
   if (!unibi_get_str(ut, str)) {

Using uv_sleep() is probably not the right way to sleep here.

@zeertzjq zeertzjq added the complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md label Sep 17, 2022
@zeertzjq zeertzjq added this to the 0.8 milestone Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior complexity:low Low-risk, self-contained. Do NOT ask "can I work on this", just read CONTRIBUTING.md tui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants