forked from aniani/vim
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Problem: When using ":sleep" the cursor is always displayed. Solution: Do not display the cursor when using ":sleep!". (Jeremy Lerner, closes #7688)
This commit is contained in:
@@ -1590,6 +1590,8 @@ tag command action ~
|
|||||||
|:sign| :sig[n] manipulate signs
|
|:sign| :sig[n] manipulate signs
|
||||||
|:silent| :sil[ent] run a command silently
|
|: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
|
||||||
|
|: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
|
|:slast| :sla[st] split window and go to last file in the
|
||||||
argument list
|
argument list
|
||||||
|:smagic| :sm[agic] :substitute with 'magic'
|
|:smagic| :sm[agic] :substitute with 'magic'
|
||||||
|
@@ -707,12 +707,12 @@ K Run a program to lookup the keyword under the
|
|||||||
not more than one line.
|
not more than one line.
|
||||||
|
|
||||||
[N]gs *gs* *:sl* *:sleep*
|
[N]gs *gs* *:sl* *:sleep*
|
||||||
:[N]sl[eep] [N] [m] Do nothing for [N] seconds. When [m] is included,
|
:[N]sl[eep] [N][m] Do nothing for [N] seconds. When [m] is included,
|
||||||
sleep for [N] milliseconds. The count for "gs" always
|
sleep for [N] milliseconds. The count for "gs" always
|
||||||
uses seconds. The default is one second. >
|
uses seconds. The default is one second. >
|
||||||
:sleep "sleep for one second
|
:sleep "sleep for one second
|
||||||
:5sleep "sleep for five seconds
|
:5sleep "sleep for five seconds
|
||||||
:sleep 100m "sleep for a hundred milliseconds
|
:sleep 100m "sleep for 100 milliseconds
|
||||||
10gs "sleep for ten seconds
|
10gs "sleep for ten seconds
|
||||||
< Can be interrupted with CTRL-C (CTRL-Break on
|
< Can be interrupted with CTRL-C (CTRL-Break on
|
||||||
MS-Windows). "gs" stands for "goto sleep".
|
MS-Windows). "gs" stands for "goto sleep".
|
||||||
|
@@ -1365,7 +1365,7 @@ EXCMD(CMD_silent, "silent", ex_wrongmodifier,
|
|||||||
EX_NEEDARG|EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
|
EX_NEEDARG|EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_sleep, "sleep", ex_sleep,
|
EXCMD(CMD_sleep, "sleep", ex_sleep,
|
||||||
EX_RANGE|EX_COUNT|EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_BANG|EX_RANGE|EX_COUNT|EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_OTHER),
|
ADDR_OTHER),
|
||||||
EXCMD(CMD_slast, "slast", ex_last,
|
EXCMD(CMD_slast, "slast", ex_last,
|
||||||
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
|
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
|
||||||
|
@@ -7225,14 +7225,17 @@ ex_sleep(exarg_T *eap)
|
|||||||
case NUL: len *= 1000L; break;
|
case NUL: len *= 1000L; break;
|
||||||
default: semsg(_(e_invarg2), eap->arg); return;
|
default: semsg(_(e_invarg2), eap->arg); return;
|
||||||
}
|
}
|
||||||
do_sleep(len);
|
|
||||||
|
// Hide the cursor if invoked with !
|
||||||
|
do_sleep(len, eap->forceit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
|
* Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
|
||||||
|
* Hide the cursor if "hide_cursor" is TRUE.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
do_sleep(long msec)
|
do_sleep(long msec, int hide_cursor)
|
||||||
{
|
{
|
||||||
long done = 0;
|
long done = 0;
|
||||||
long wait_now;
|
long wait_now;
|
||||||
@@ -7244,7 +7247,11 @@ do_sleep(long msec)
|
|||||||
ELAPSED_INIT(start_tv);
|
ELAPSED_INIT(start_tv);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
cursor_on();
|
if (hide_cursor)
|
||||||
|
cursor_off();
|
||||||
|
else
|
||||||
|
cursor_on();
|
||||||
|
|
||||||
out_flush_cursor(FALSE, FALSE);
|
out_flush_cursor(FALSE, FALSE);
|
||||||
while (!got_int && done < msec)
|
while (!got_int && done < msec)
|
||||||
{
|
{
|
||||||
|
@@ -993,7 +993,7 @@ getcount:
|
|||||||
// something different from CTRL-N. Can't be avoided.
|
// something different from CTRL-N. Can't be avoided.
|
||||||
while ((c = vpeekc()) <= 0 && towait > 0L)
|
while ((c = vpeekc()) <= 0 && towait > 0L)
|
||||||
{
|
{
|
||||||
do_sleep(towait > 50L ? 50L : towait);
|
do_sleep(towait > 50L ? 50L : towait, FALSE);
|
||||||
towait -= 50L;
|
towait -= 50L;
|
||||||
}
|
}
|
||||||
if (c > 0)
|
if (c > 0)
|
||||||
@@ -6230,7 +6230,7 @@ nv_g_cmd(cmdarg_T *cap)
|
|||||||
* "gs": Goto sleep.
|
* "gs": Goto sleep.
|
||||||
*/
|
*/
|
||||||
case 's':
|
case 's':
|
||||||
do_sleep(cap->count1 * 1000L);
|
do_sleep(cap->count1 * 1000L, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -42,7 +42,7 @@ void free_cd_dir(void);
|
|||||||
void post_chdir(cdscope_T scope);
|
void post_chdir(cdscope_T scope);
|
||||||
int changedir_func(char_u *new_dir, int forceit, cdscope_T scope);
|
int changedir_func(char_u *new_dir, int forceit, cdscope_T scope);
|
||||||
void ex_cd(exarg_T *eap);
|
void ex_cd(exarg_T *eap);
|
||||||
void do_sleep(long msec);
|
void do_sleep(long msec, int hide_cursor);
|
||||||
void ex_may_print(exarg_T *eap);
|
void ex_may_print(exarg_T *eap);
|
||||||
void ex_redraw(exarg_T *eap);
|
void ex_redraw(exarg_T *eap);
|
||||||
int vim_mkdir_emsg(char_u *name, int prot);
|
int vim_mkdir_emsg(char_u *name, int prot);
|
||||||
|
@@ -2713,7 +2713,7 @@ out_str_cf(char_u *s)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
++p;
|
++p;
|
||||||
do_sleep(duration);
|
do_sleep(duration, FALSE);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
// Rely on the terminal library to sleep.
|
// Rely on the terminal library to sleep.
|
||||||
|
@@ -246,6 +246,7 @@ NEW_TESTS = \
|
|||||||
test_shortpathname \
|
test_shortpathname \
|
||||||
test_signals \
|
test_signals \
|
||||||
test_signs \
|
test_signs \
|
||||||
|
test_sleep \
|
||||||
test_smartindent \
|
test_smartindent \
|
||||||
test_sort \
|
test_sort \
|
||||||
test_sound \
|
test_sound \
|
||||||
@@ -472,6 +473,7 @@ NEW_TESTS_RES = \
|
|||||||
test_shortpathname.res \
|
test_shortpathname.res \
|
||||||
test_signals.res \
|
test_signals.res \
|
||||||
test_signs.res \
|
test_signs.res \
|
||||||
|
test_sleep.res \
|
||||||
test_smartindent.res \
|
test_smartindent.res \
|
||||||
test_sort.res \
|
test_sort.res \
|
||||||
test_sound.res \
|
test_sound.res \
|
||||||
|
26
src/testdir/test_sleep.vim
Normal file
26
src/testdir/test_sleep.vim
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
" Test for sleep and sleep! commands
|
||||||
|
|
||||||
|
func! s:get_time_ms()
|
||||||
|
let timestr = reltimestr(reltime())
|
||||||
|
let dotidx = stridx(timestr, '.')
|
||||||
|
let sec = str2nr(timestr[:dotidx])
|
||||||
|
let msec = str2nr(timestr[dotidx + 1:])
|
||||||
|
return (sec * 1000) + (msec / 1000)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func! s:assert_takes_longer(cmd, time_ms)
|
||||||
|
let start = s:get_time_ms()
|
||||||
|
execute a:cmd
|
||||||
|
let end = s:get_time_ms()
|
||||||
|
call assert_true(end - start >=# a:time_ms)
|
||||||
|
endfun
|
||||||
|
|
||||||
|
func! Test_sleep_bang()
|
||||||
|
call s:assert_takes_longer('sleep 50m', 50)
|
||||||
|
call s:assert_takes_longer('sleep! 50m', 50)
|
||||||
|
call s:assert_takes_longer('sl 50m', 50)
|
||||||
|
call s:assert_takes_longer('sl! 50m', 50)
|
||||||
|
call s:assert_takes_longer('1sleep', 1000)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2366,
|
||||||
/**/
|
/**/
|
||||||
2365,
|
2365,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user