To Reproduce
gvim --clean:sleep! 3 (the command is described at :help :sleep!). gVim sleeps for 3 seconds, but doesn't hide the cursor.Expected behavior
The cursor should be hidden while gVim sleeps.
Environment:
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
cc @jeremy-quicklearner via #7688
Also, not sure whether it's working as intended, or if it's just corner case, but the cursor is no longer hidden when a timer callback is processed:
vim -Nu NONE +'au CmdlineLeave : call timer_start(0, {-> 0})'
:sleep! 3
I don't have much insight into how Vim draws the cursor, but I can confirm that I only tested sleep! using Vim on the command-line.
After looking at the code, it seems that cursor_off() only applies to the terminal - not the GUI. It may be possible to modify update_screen() in drawscreen.c so that it calls gui_undraw_cursor() and then skips gui_update_cursor() if sleep! is ongoing. For that, we'd need some sort of ":sleep! is ongoing" flag.
As for the timer callback issue @lacygoill commented on: Looks like sleep and sleep! don't block Vim's event loop. Makes sense. I expect fixing this would require :sleep! to set some flag that later gets checked as part of the callback's event.
So to fix both of these issues, we need a flag that's accessible to both drawscreen.c and term.c. I don't know where best to put it... Perhaps someplace higher up where it can be passed down as a parameter. Maybe someone more experienced can weigh in?
We already have the cursor_is_off flag in term.c. We could add a "cursor_is_sleeping" flag there, with functions to set/reset it (making sure reset is always used after set), and a function to get the current value. That seems the cleanest way. Then when the cursor is displayed anywhere, the flag can be checked by calling that function. In cursor_on_force() the flag can be used directly.
Great! cursor_off() is already called by update_screen() in drawscreen.c, so I agree putting the flag in term.c with set/get functions is the clean choice. I'll give this a try within a few days.