Skip to content

Commit f3402b1

Browse files
committed
patch 8.0.0884: can't specify the wait time for term_wait()
Problem: Can't specify the wait time for term_wait(). Solution: Add an otional second argument.
1 parent 1c86409 commit f3402b1

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

runtime/doc/eval.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ term_list() List get the list of terminal buffers
23812381
term_scrape({buf}, {row}) List get row of a terminal screen
23822382
term_sendkeys({buf}, {keys}) none send keystrokes to a terminal
23832383
term_start({cmd}, {options}) Job open a terminal window and run a job
2384-
term_wait({buf}) Number wait for screen to be updated
2384+
term_wait({buf} [, {time}]) Number wait for screen to be updated
23852385
test_alloc_fail({id}, {countdown}, {repeat})
23862386
none make memory allocation fail
23872387
test_autochdir() none enable 'autochdir' during startup
@@ -8041,9 +8041,11 @@ term_start({cmd}, {options}) *term_start()*
80418041
the command name.
80428042
{only available when compiled with the |+terminal| feature}
80438043

8044-
term_wait({buf}) *term_wait()*
8044+
term_wait({buf} [, {time}]) *term_wait()*
80458045
Wait for pending updates of {buf} to be handled.
80468046
{buf} is used as with |term_getsize()|.
8047+
{time} is how long to wait for updates to arrive in msec. If
8048+
not set then 10 msec will be used.
80478049
{only available when compiled with the |+terminal| feature}
80488050

80498051
test_alloc_fail({id}, {countdown}, {repeat}) *test_alloc_fail()*

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static struct fst
843843
{"term_scrape", 2, 2, f_term_scrape},
844844
{"term_sendkeys", 2, 2, f_term_sendkeys},
845845
{"term_start", 1, 2, f_term_start},
846-
{"term_wait", 1, 1, f_term_wait},
846+
{"term_wait", 1, 2, f_term_wait},
847847
#endif
848848
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
849849
{"test_autochdir", 0, 0, f_test_autochdir},

src/terminal.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* that buffer, attributes come from the scrollback buffer tl_scrollback.
3737
*
3838
* TODO:
39-
* - Add argument to term_wait() for waiting time.
4039
* - For the scrollback buffer store lines in the buffer, only attributes in
4140
* tl_scrollback.
4241
* - When the job ends:
@@ -2248,12 +2247,15 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
22482247
}
22492248
else
22502249
{
2250+
long wait = 10L;
2251+
22512252
mch_check_messages();
22522253
parse_queued_messages();
22532254

2254-
/* Wait for 10 msec for any channel I/O. */
2255-
/* TODO: use delay from optional argument */
2256-
ui_delay(10L, TRUE);
2255+
/* Wait for some time for any channel I/O. */
2256+
if (argvars[1].v_type != VAR_UNKNOWN)
2257+
wait = get_tv_number(&argvars[1]);
2258+
ui_delay(wait, TRUE);
22572259
mch_check_messages();
22582260

22592261
/* Flushing messages on channels is hopefully sufficient.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
884,
772774
/**/
773775
883,
774776
/**/

0 commit comments

Comments
 (0)