Patch 8.2.2366

5 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 16, 2021, 2:22:04 PM1/16/21
to vim...@googlegroups.com

Patch 8.2.2366
Problem: When using ":sleep" the cursor is always displayed.
Solution: Do not display the cursor when using ":sleep!". (Jeremy Lerner,
closes #7688)
Files: runtime/doc/index.txt, runtime/doc/various.txt, src/ex_cmds.h,
src/ex_docmd.c, src/normal.c, src/proto/ex_docmd.pro, src/term.c,
src/testdir/Make_all.mak, src/testdir/test_sleep.vim


*** ../vim-8.2.2365/runtime/doc/index.txt 2020-08-09 14:03:51.541367942 +0200
--- runtime/doc/index.txt 2021-01-16 19:44:40.528878222 +0100
***************
*** 1581,1586 ****
--- 1590,1597 ----
|: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'
*** ../vim-8.2.2365/runtime/doc/various.txt 2020-06-12 20:19:37.972526321 +0200
--- runtime/doc/various.txt 2021-01-16 19:44:40.528878222 +0100
***************
*** 698,709 ****
not more than one line.

[N]gs *gs* *:sl* *:sleep*
! :[N]sl[eep] [N] [m] Do nothing for [N] seconds. When [m] is included,
sleep for [N] milliseconds. The count for "gs" always
uses seconds. The default is one second. >
:sleep "sleep for one second
:5sleep "sleep for five seconds
! :sleep 100m "sleep for a hundred milliseconds
10gs "sleep for ten seconds
< Can be interrupted with CTRL-C (CTRL-Break on
MS-Windows). "gs" stands for "goto sleep".
--- 707,718 ----
not more than one line.

[N]gs *gs* *:sl* *:sleep*
! :[N]sl[eep] [N][m] Do nothing for [N] seconds. When [m] is included,
sleep for [N] milliseconds. The count for "gs" always
uses seconds. The default is one second. >
:sleep "sleep for one second
:5sleep "sleep for five seconds
! :sleep 100m "sleep for 100 milliseconds
10gs "sleep for ten seconds
< Can be interrupted with CTRL-C (CTRL-Break on
MS-Windows). "gs" stands for "goto sleep".
*** ../vim-8.2.2365/src/ex_cmds.h 2020-12-26 15:39:24.619550795 +0100
--- src/ex_cmds.h 2021-01-16 19:44:40.528878222 +0100
***************
*** 1365,1371 ****
EX_NEEDARG|EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_sleep, "sleep", ex_sleep,
! EX_RANGE|EX_COUNT|EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_slast, "slast", ex_last,
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
--- 1365,1371 ----
EX_NEEDARG|EX_EXTRA|EX_BANG|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_sleep, "sleep", ex_sleep,
! EX_BANG|EX_RANGE|EX_COUNT|EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_slast, "slast", ex_last,
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
*** ../vim-8.2.2365/src/ex_docmd.c 2021-01-14 21:40:13.456592104 +0100
--- src/ex_docmd.c 2021-01-16 20:11:37.259972628 +0100
***************
*** 7225,7238 ****
case NUL: len *= 1000L; break;
default: semsg(_(e_invarg2), eap->arg); return;
}
! do_sleep(len);
}

/*
* Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
*/
void
! do_sleep(long msec)
{
long done = 0;
long wait_now;
--- 7225,7241 ----
case NUL: len *= 1000L; break;
default: semsg(_(e_invarg2), eap->arg); return;
}
!
! // Hide the cursor if invoked with !
! do_sleep(len, eap->forceit);
}

/*
* Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
+ * Hide the cursor if "hide_cursor" is TRUE.
*/
void
! do_sleep(long msec, int hide_cursor)
{
long done = 0;
long wait_now;
***************
*** 7244,7250 ****
ELAPSED_INIT(start_tv);
# endif

! cursor_on();
out_flush_cursor(FALSE, FALSE);
while (!got_int && done < msec)
{
--- 7247,7257 ----
ELAPSED_INIT(start_tv);
# endif

! if (hide_cursor)
! cursor_off();
! else
! cursor_on();
!
out_flush_cursor(FALSE, FALSE);
while (!got_int && done < msec)
{
*** ../vim-8.2.2365/src/normal.c 2020-12-21 19:59:04.569197722 +0100
--- src/normal.c 2021-01-16 20:11:05.208053362 +0100
***************
*** 993,999 ****
// something different from CTRL-N. Can't be avoided.
while ((c = vpeekc()) <= 0 && towait > 0L)
{
! do_sleep(towait > 50L ? 50L : towait);
towait -= 50L;
}
if (c > 0)
--- 993,999 ----
// something different from CTRL-N. Can't be avoided.
while ((c = vpeekc()) <= 0 && towait > 0L)
{
! do_sleep(towait > 50L ? 50L : towait, FALSE);
towait -= 50L;
}
if (c > 0)
***************
*** 6230,6236 ****
* "gs": Goto sleep.
*/
case 's':
! do_sleep(cap->count1 * 1000L);
break;

/*
--- 6230,6236 ----
* "gs": Goto sleep.
*/
case 's':
! do_sleep(cap->count1 * 1000L, FALSE);
break;

/*
*** ../vim-8.2.2365/src/proto/ex_docmd.pro 2020-12-12 14:33:37.096920916 +0100
--- src/proto/ex_docmd.pro 2021-01-16 19:44:40.532878208 +0100
***************
*** 42,48 ****
void post_chdir(cdscope_T scope);
int changedir_func(char_u *new_dir, int forceit, cdscope_T scope);
void ex_cd(exarg_T *eap);
! void do_sleep(long msec);
void ex_may_print(exarg_T *eap);
void ex_redraw(exarg_T *eap);
int vim_mkdir_emsg(char_u *name, int prot);
--- 42,48 ----
void post_chdir(cdscope_T scope);
int changedir_func(char_u *new_dir, int forceit, cdscope_T scope);
void ex_cd(exarg_T *eap);
! void do_sleep(long msec, int hide_cursor);
void ex_may_print(exarg_T *eap);
void ex_redraw(exarg_T *eap);
int vim_mkdir_emsg(char_u *name, int prot);
*** ../vim-8.2.2365/src/term.c 2021-01-16 11:21:37.387048645 +0100
--- src/term.c 2021-01-16 20:11:10.100041071 +0100
***************
*** 2713,2719 ****
else
{
++p;
! do_sleep(duration);
}
# else
// Rely on the terminal library to sleep.
--- 2713,2719 ----
else
{
++p;
! do_sleep(duration, FALSE);
}
# else
// Rely on the terminal library to sleep.
*** ../vim-8.2.2365/src/testdir/Make_all.mak 2020-10-28 22:46:38.914990895 +0100
--- src/testdir/Make_all.mak 2021-01-16 19:49:24.943902203 +0100
***************
*** 246,251 ****
--- 246,252 ----
test_shortpathname \
test_signals \
test_signs \
+ test_sleep \
test_smartindent \
test_sort \
test_sound \
***************
*** 472,477 ****
--- 473,479 ----
test_shortpathname.res \
test_signals.res \
test_signs.res \
+ test_sleep.res \
test_smartindent.res \
test_sort.res \
test_sound.res \
*** ../vim-8.2.2365/src/testdir/test_sleep.vim 2021-01-16 20:20:11.482617939 +0100
--- src/testdir/test_sleep.vim 2021-01-16 20:13:34.423673000 +0100
***************
*** 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
*** ../vim-8.2.2365/src/version.c 2021-01-16 19:01:48.944919906 +0100
--- src/version.c 2021-01-16 20:09:46.664248479 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2366,
/**/

--
hundred-and-one symptoms of being an internet addict:
168. You have your own domain name.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages