diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 9ee75ea950..d81d59c56f 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1569,6 +1569,8 @@ tag command action ~ |:sign| :sig[n] manipulate signs |:silent| :sil[ent] run a command silently |:sleep| :sl[eep] do nothing for a few seconds +|:sleep!| :sl[eep]! do nothing for a few seconds, without the + cursor visible |:slast| :sla[st] split window and go to last file in the argument list |:smagic| :sm[agic] :substitute with 'magic' diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 5049439337..6074931565 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -552,8 +552,7 @@ gO Show a filetype-specific, navigable "outline" of the Queued messages are processed during the sleep. *:sl!* *:sleep!* -:[N]sl[eep]! [N][m] Same as above. Unlike Vim, it does not hide the - cursor. |vim-differences| +:[N]sl[eep]! [N][m] Same as above, but hide the cursor. ============================================================================== 2. Using Vim like less or more *less* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7021e1d3e2..bfef5d5d4a 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -670,7 +670,6 @@ Commands: - :promptrepl - :scriptversion (always version 1) - :shell -- :sleep! (does not hide the cursor; same as :sleep) - :smile - :tearoff - :cstag diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b7c83ea1ac..b32a8b867f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6101,7 +6101,9 @@ static void ex_sleep(exarg_T *eap) default: semsg(_(e_invarg2), eap->arg); return; } - do_sleep(len, false); + + // Hide the cursor if invoked with ! + do_sleep(len, eap->forceit); } /// Sleep for "msec" milliseconds, but return early on CTRL-C. diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index d7c0657820..edf826a1d9 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -361,4 +361,38 @@ describe('ui/cursor', function() end end) end) + + it(':sleep does not hide cursor when sleeping', function() + n.feed(':sleep 100m | echo 42\n') + screen:expect({ + grid = [[ + ^ | + {1:~ }|*3 + :sleep 100m | echo 42 | + ]], + timeout = 100, + }) + screen:expect([[ + ^ | + {1:~ }|*3 + 42 | + ]]) + end) + + it(':sleep! hides cursor when sleeping', function() + n.feed(':sleep! 100m | echo 42\n') + screen:expect({ + grid = [[ + | + {1:~ }|*3 + :sleep! 100m | echo 42 | + ]], + timeout = 100, + }) + screen:expect([[ + ^ | + {1:~ }|*3 + 42 | + ]]) + end) end)