aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-21 14:07:50 -0700
committerGitHub <noreply@github.com>2019-09-21 14:07:50 -0700
commitfd82ce4a3a9c9833e07db079debf6c9b94a2cfd3 (patch)
tree30520e000a28c2b2099c641ce33826aea0c07541
parentb3e56957f8e9468497e5db508d97d7b560ccfe85 (diff)
parent111d34849a0670842b56c17c3922dbf0576bb39b (diff)
downloadrneovim-fd82ce4a3a9c9833e07db079debf6c9b94a2cfd3.tar.gz
rneovim-fd82ce4a3a9c9833e07db079debf6c9b94a2cfd3.tar.bz2
rneovim-fd82ce4a3a9c9833e07db079debf6c9b94a2cfd3.zip
Merge #11060 from janlazo/vim-8.1.1783
vim-patch:8.0.{1109,1529,1539,1621,1733,1771,1776},8.1.{1783,2054,2058}
-rw-r--r--runtime/doc/eval.txt2
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/ex_cmds.lua2
-rw-r--r--src/nvim/ex_docmd.c17
-rw-r--r--src/nvim/mark.c2
-rw-r--r--src/nvim/syntax.c2
-rw-r--r--src/nvim/testdir/shared.vim77
-rw-r--r--src/nvim/testdir/test_autocmd.vim4
-rw-r--r--src/nvim/testdir/test_clientserver.vim13
-rw-r--r--src/nvim/testdir/test_compiler.vim10
-rw-r--r--src/nvim/testdir/test_popup.vim52
-rw-r--r--src/nvim/testdir/test_quotestar.vim22
-rw-r--r--src/nvim/testdir/test_syntax.vim3
-rw-r--r--src/nvim/testdir/test_timers.vim17
14 files changed, 168 insertions, 59 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index bac7709ef5..5e6bfd0dbc 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6657,7 +6657,7 @@ remote_expr({server}, {string} [, {idvar} [, {timeout}]])
between (not at the end), like with join(expr, "\n").
If {idvar} is present and not empty, it is taken as the name
of a variable and a {serverid} for later use with
- remote_read() is stored there.
+ |remote_read()| is stored there.
If {timeout} is given the read times out after this many
seconds. Otherwise a timeout of 600 seconds is used.
See also |clientserver| |RemoteReply|.
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 7d45787fae..be761afa1f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7004,6 +7004,8 @@ static int assert_equalfile(typval_T *argvars)
break;
}
}
+ fclose(fd1);
+ fclose(fd2);
}
}
if (IObuff[0] != NUL) {
@@ -18444,6 +18446,7 @@ static void timer_due_cb(TimeWatcher *tw, void *data)
timer_T *timer = (timer_T *)data;
int save_did_emsg = did_emsg;
int save_called_emsg = called_emsg;
+ const bool save_ex_pressedreturn = get_pressedreturn();
if (timer->stopped || timer->paused) {
return;
@@ -18472,6 +18475,7 @@ static void timer_due_cb(TimeWatcher *tw, void *data)
}
did_emsg = save_did_emsg;
called_emsg = save_called_emsg;
+ set_pressedreturn(save_ex_pressedreturn);
if (timer->emsg_count >= 3) {
timer_stop(timer);
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 8c0d22809f..a709acd4ef 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -1632,7 +1632,7 @@ return {
command='marks',
flags=bit.bor(EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='do_marks',
+ func='ex_marks',
},
{
command='match',
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 72d39adb3e..a6931f3acd 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -77,7 +77,7 @@
#include "nvim/api/private/helpers.h"
static int quitmore = 0;
-static int ex_pressedreturn = FALSE;
+static bool ex_pressedreturn = false;
/// Whether ":lcd" or ":tcd" was produced for a session.
static int did_lcd;
@@ -1278,14 +1278,14 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|| getline_equal(fgetline, cookie, getexline))
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
ea.cmd = (char_u *)"+";
- ex_pressedreturn = TRUE;
+ ex_pressedreturn = true;
}
/* ignore comment and empty lines */
if (*ea.cmd == '"')
goto doend;
if (*ea.cmd == NUL) {
- ex_pressedreturn = TRUE;
+ ex_pressedreturn = true;
goto doend;
}
@@ -10131,6 +10131,17 @@ static void ex_folddo(exarg_T *eap)
ml_clearmarked(); // clear rest of the marks
}
+bool get_pressedreturn(void)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ return ex_pressedreturn;
+}
+
+void set_pressedreturn(bool val)
+{
+ ex_pressedreturn = val;
+}
+
static void ex_terminal(exarg_T *eap)
{
char ex_cmd[1024];
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index e103d3cb55..e8f1651a6e 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -616,7 +616,7 @@ static char_u *mark_line(pos_T *mp, int lead_len)
/*
* print the marks
*/
-void do_marks(exarg_T *eap)
+void ex_marks(exarg_T *eap)
{
char_u *arg = eap->arg;
int i;
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 5a61238d8c..675d484d67 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -7569,8 +7569,8 @@ void highlight_changed(void)
{
int id;
char_u userhl[30]; // use 30 to avoid compiler warning
- int id_SNC = -1;
int id_S = -1;
+ int id_SNC = 0;
int hlcnt;
need_highlight_changed = FALSE;
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index df512e2e3f..84f636077d 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -135,39 +135,80 @@ endfunc
" Wait for up to five seconds for "expr" to become true. "expr" can be a
" stringified expression to evaluate, or a funcref without arguments.
+" Using a lambda works best. Example:
+" call WaitFor({-> status == "ok"})
"
" A second argument can be used to specify a different timeout in msec.
"
-" Return time slept in milliseconds. With the +reltime feature this can be
-" more than the actual waiting time. Without +reltime it can also be less.
+" When successful the time slept is returned.
+" When running into the timeout an exception is thrown, thus the function does
+" not return.
func WaitFor(expr, ...)
let timeout = get(a:000, 0, 5000)
+ let slept = s:WaitForCommon(a:expr, v:null, timeout)
+ if slept < 0
+ throw 'WaitFor() timed out after ' . timeout . ' msec'
+ endif
+ return slept
+endfunc
+
+" Wait for up to five seconds for "assert" to return zero. "assert" must be a
+" (lambda) function containing one assert function. Example:
+" call WaitForAssert({-> assert_equal("dead", job_status(job)})
+"
+" A second argument can be used to specify a different timeout in msec.
+"
+" Return zero for success, one for failure (like the assert function).
+func WaitForAssert(assert, ...)
+ let timeout = get(a:000, 0, 5000)
+ if s:WaitForCommon(v:null, a:assert, timeout) < 0
+ return 1
+ endif
+ return 0
+endfunc
+
+" Common implementation of WaitFor() and WaitForAssert().
+" Either "expr" or "assert" is not v:null
+" Return the waiting time for success, -1 for failure.
+func s:WaitForCommon(expr, assert, timeout)
" using reltime() is more accurate, but not always available
+ let slept = 0
if has('reltime')
let start = reltime()
- else
- let slept = 0
endif
- if type(a:expr) == v:t_func
- let Test = a:expr
- else
- let Test = {-> eval(a:expr) }
- endif
- for i in range(timeout / 10)
- if Test()
- if has('reltime')
- return float2nr(reltimefloat(reltime(start)) * 1000)
- endif
+
+ while 1
+ if type(a:expr) == v:t_func
+ let success = a:expr()
+ elseif type(a:assert) == v:t_func
+ let success = a:assert() == 0
+ else
+ let success = eval(a:expr)
+ endif
+ if success
return slept
endif
- if !has('reltime')
- let slept += 10
+
+ if slept >= a:timeout
+ break
+ endif
+ if type(a:assert) == v:t_func
+ " Remove the error added by the assert function.
+ call remove(v:errors, -1)
endif
+
sleep 10m
- endfor
- throw 'WaitFor() timed out after ' . timeout . ' msec'
+ if has('reltime')
+ let slept = float2nr(reltimefloat(reltime(start)) * 1000)
+ else
+ let slept += 10
+ endif
+ endwhile
+
+ return -1 " timed out
endfunc
+
" Wait for up to a given milliseconds.
" With the +timers feature this waits for key-input by getchar(), Resume()
" feeds key-input and resumes process. Return time waited in milliseconds.
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 5848940a2b..4dd48beef4 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -1344,11 +1344,11 @@ func Test_Changed_FirstTime()
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
call assert_equal('running', term_getstatus(buf))
" Wait for the ruler (in the status line) to be shown.
- call WaitFor({-> term_getline(buf, 3) =~# '\<All$'})
+ call WaitForAssert({-> assert_match('\<All$', term_getline(buf, 3))})
" It's only adding autocmd, so that no event occurs.
call term_sendkeys(buf, ":au! TextChanged <buffer> call writefile(['No'], 'Xchanged.txt')\<cr>")
call term_sendkeys(buf, "\<C-\\>\<C-N>:qa!\<cr>")
- call WaitFor({-> term_getstatus(buf) == 'finished'})
+ call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
call assert_equal([''], readfile('Xchanged.txt'))
" clean up
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index 813cb338a5..3377f86126 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -28,12 +28,11 @@ func Test_client_server()
let name = 'XVIMTEST'
let cmd .= ' --servername ' . name
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
- call WaitFor({-> job_status(job) == "run"})
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
" Takes a short while for the server to be active.
" When using valgrind it takes much longer.
- call WaitFor('serverlist() =~ "' . name . '"')
- call assert_match(name, serverlist())
+ call WaitForAssert({-> assert_match(name, serverlist())})
call remote_foreground(name)
@@ -54,12 +53,10 @@ func Test_client_server()
endif
" Wait for the server to be up and answering requests.
sleep 100m
- call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""')
- call assert_true(remote_expr(name, "v:version", "", 1) != "")
+ call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")})
call remote_send(name, ":let testvar = 'maybe'\<CR>")
- call WaitFor('remote_expr("' . name . '", "testvar", "", 1) == "maybe"')
- call assert_equal('maybe', remote_expr(name, "testvar", "", 2))
+ call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
endif
call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241')
@@ -94,7 +91,7 @@ func Test_client_server()
call remote_send(name, ":qa!\<CR>")
try
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
if job_status(job) != 'dead'
call assert_report('Server did not exit')
diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim
index 46c14d8bc3..40d3cdbdae 100644
--- a/src/nvim/testdir/test_compiler.vim
+++ b/src/nvim/testdir/test_compiler.vim
@@ -10,6 +10,10 @@ func Test_compiler()
unlet $LANG
endif
+ " %:S does not work properly with 'shellslash' set
+ let save_shellslash = &shellslash
+ set noshellslash
+
e Xfoo.pl
compiler perl
call assert_equal('perl', b:current_compiler)
@@ -24,9 +28,11 @@ func Test_compiler()
w!
call feedkeys(":make\<CR>\<CR>", 'tx')
let a=execute('clist')
- call assert_match("\n 1 Xfoo.pl:3: Global symbol \"\$foo\" "
- \ . "requires explicit package name", a)
+ call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" '
+ \ . 'requires explicit package name', a)
+
+ let &shellslash = save_shellslash
call delete('Xfoo.pl')
bw!
endfunc
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 53df30bb19..c63269e5d2 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -1,6 +1,7 @@
" Test for completion menu
source shared.vim
+source screendump.vim
let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
let g:setting = ''
@@ -680,18 +681,15 @@ func Test_popup_and_window_resize()
call term_sendkeys(buf, "\<c-v>")
call term_wait(buf, 100)
" popup first entry "!" must be at the top
- call WaitFor({-> term_getline(buf, 1) =~ "^!"})
- call assert_match('^!\s*$', term_getline(buf, 1))
+ call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, 1))})
exe 'resize +' . (h - 1)
call term_wait(buf, 100)
redraw!
" popup shifted down, first line is now empty
- call WaitFor({-> term_getline(buf, 1) == ""})
- call assert_equal('', term_getline(buf, 1))
+ call WaitForAssert({-> assert_equal('', term_getline(buf, 1))})
sleep 100m
" popup is below cursor line and shows first match "!"
- call WaitFor({-> term_getline(buf, term_getcursor(buf)[0] + 1) =~ "^!"})
- call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))
+ call WaitForAssert({-> assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1))})
" cursor line also shows !
call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0]))
bwipe!
@@ -735,6 +733,38 @@ func Test_popup_and_preview_autocommand()
bw!
endfunc
+func Test_popup_position()
+ if !CanRunVimInTerminal()
+ return
+ endif
+ call writefile([
+ \ '123456789_123456789_123456789_a',
+ \ '123456789_123456789_123456789_b',
+ \ ' 123',
+ \ ], 'Xtest')
+ let buf = RunVimInTerminal('Xtest', {})
+ call term_sendkeys(buf, ":vsplit\<CR>")
+
+ " default pumwidth in left window: overlap in right window
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_01', {'rows': 8})
+ call term_sendkeys(buf, "\<Esc>u")
+
+ " default pumwidth: fill until right of window
+ call term_sendkeys(buf, "\<C-W>l")
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_02', {'rows': 8})
+
+ " larger pumwidth: used as minimum width
+ call term_sendkeys(buf, "\<Esc>u")
+ call term_sendkeys(buf, ":set pumwidth=30\<CR>")
+ call term_sendkeys(buf, "GA\<C-N>")
+ call VerifyScreenDump(buf, 'Test_popup_position_03', {'rows': 8})
+
+ call term_sendkeys(buf, "\<Esc>u")
+ call StopVimInTerminal(buf)
+ call delete('Xtest')
+endfunc
func Test_popup_complete_backwards()
new
@@ -746,6 +776,16 @@ func Test_popup_complete_backwards()
bwipe!
endfunc
+func Test_popup_complete_backwards_ctrl_p()
+ new
+ call setline(1, ['Post', 'Port', 'Po'])
+ let expected=['Post', 'Port', 'Port']
+ call cursor(3,2)
+ call feedkeys("A\<C-P>\<C-N>rt\<cr>", 'tx')
+ call assert_equal(expected, getline(1,'$'))
+ bwipe!
+endfunc
+
fun! Test_complete_o_tab()
throw 'skipped: Nvim does not support test_override()'
let s:o_char_pressed = 0
diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim
index b83fbe40e8..ce5a9ee827 100644
--- a/src/nvim/testdir/test_quotestar.vim
+++ b/src/nvim/testdir/test_quotestar.vim
@@ -54,34 +54,33 @@ func Do_test_quotestar_for_x11()
" Make sure a previous server has exited
try
call remote_send(name, ":qa!\<CR>")
- call WaitFor('serverlist() !~ "' . name . '"')
catch /E241:/
endtry
- call assert_notmatch(name, serverlist())
+ call WaitForAssert({-> assert_notmatch(name, serverlist())})
let cmd .= ' --servername ' . name
let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'})
- call WaitFor({-> job_status(job) == "run"})
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
" Takes a short while for the server to be active.
- call WaitFor('serverlist() =~ "' . name . '"')
+ call WaitForAssert({-> assert_match(name, serverlist())})
" Wait for the server to be up and answering requests. One second is not
" always sufficient.
- call WaitFor('remote_expr("' . name . '", "v:version", "", 2) != ""')
+ call WaitForAssert({-> assert_notequal('', remote_expr(name, "v:version", "", 2))})
" Clear the *-register of this vim instance and wait for it to be picked up
" by the server.
let @* = 'no'
call remote_foreground(name)
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "no"')
+ call WaitForAssert({-> assert_equal("no", remote_expr(name, "@*", "", 1))})
" Set the * register on the server.
call remote_send(name, ":let @* = 'yes'\<CR>")
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"')
+ call WaitForAssert({-> assert_equal("yes", remote_expr(name, "@*", "", 1))})
" Check that the *-register of this vim instance is changed as expected.
- call WaitFor('@* == "yes"')
+ call WaitForAssert({-> assert_equal("yes", @*)})
" Handle the large selection over 262040 byte.
let length = 262044
@@ -109,18 +108,17 @@ func Do_test_quotestar_for_x11()
call remote_send(name, ":gui -f\<CR>")
endif
" Wait for the server in the GUI to be up and answering requests.
- call WaitFor('remote_expr("' . name . '", "has(\"gui_running\")", "", 1) =~ "1"')
+ call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))})
call remote_send(name, ":let @* = 'maybe'\<CR>")
- call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"')
- call assert_equal('maybe', remote_expr(name, "@*", "", 2))
+ call WaitForAssert({-> assert_equal("maybe", remote_expr(name, "@*", "", 2))})
call assert_equal('maybe', @*)
endif
call remote_send(name, ":qa!\<CR>")
try
- call WaitFor({-> job_status(job) == "dead"})
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
if job_status(job) != 'dead'
call assert_report('Server did not exit')
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index 598a00476c..b9310e2168 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -1,6 +1,7 @@
" Test for syntax and syntax iskeyword option
source view_util.vim
+source screendump.vim
func GetSyntaxItem(pat)
let c = ''
@@ -526,7 +527,7 @@ func Test_syntax_c()
let $COLORFGBG = '15;0'
let buf = RunVimInTerminal('Xtest.c', {})
- call VerifyScreenDump(buf, 'Test_syntax_c_01')
+ call VerifyScreenDump(buf, 'Test_syntax_c_01', {})
call StopVimInTerminal(buf)
let $COLORFGBG = ''
diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim
index 24c735865c..bd63d94729 100644
--- a/src/nvim/testdir/test_timers.vim
+++ b/src/nvim/testdir/test_timers.vim
@@ -141,7 +141,7 @@ endfunc
func Test_delete_myself()
let g:called = 0
let t = timer_start(10, 'StopMyself', {'repeat': -1})
- call WaitFor('g:called == 2')
+ call WaitForAssert({-> assert_equal(2, g:called)})
call assert_equal(2, g:called)
call assert_equal([], timer_info(t))
endfunc
@@ -208,7 +208,7 @@ func Test_timer_errors()
let g:call_count = 0
let timer = timer_start(10, 'FuncWithError', {'repeat': -1})
" Timer will be stopped after failing 3 out of 3 times.
- call WaitFor('g:call_count == 3')
+ call WaitForAssert({-> assert_equal(3, g:call_count)})
sleep 50m
call assert_equal(3, g:call_count)
endfunc
@@ -226,7 +226,7 @@ func Test_timer_catch_error()
let g:call_count = 0
let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4})
" Timer will not be stopped.
- call WaitFor('g:call_count == 4')
+ call WaitForAssert({-> assert_equal(4, g:call_count)})
sleep 50m
call assert_equal(4, g:call_count)
endfunc
@@ -252,4 +252,15 @@ func Test_peek_and_get_char()
call timer_stop(intr)
endfunc
+func Test_ex_mode()
+ " Function with an empty line.
+ func Foo(...)
+
+ endfunc
+ let timer = timer_start(40, function('g:Foo'), {'repeat':-1})
+ " This used to throw error E749.
+ exe "normal Qsleep 100m\rvi\r"
+ call timer_stop(timer)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab