aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/provider/clipboard.vim18
-rw-r--r--src/nvim/ex_docmd.c2
-rw-r--r--src/nvim/testdir/load.vim2
-rw-r--r--src/nvim/testdir/runtest.vim15
-rw-r--r--src/nvim/testdir/shared.vim22
-rw-r--r--src/nvim/testdir/test_popup.vim6
-rw-r--r--src/nvim/testdir/test_syntax.vim35
-rw-r--r--test/functional/core/job_spec.lua5
-rw-r--r--test/functional/eval/timer_spec.lua3
9 files changed, 89 insertions, 19 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index ce140b0948..e33dc31f6d 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -159,9 +159,7 @@ function! s:clipboard.set(lines, regtype, reg) abort
end
if s:selections[a:reg].owner > 0
- " The previous provider instance should exit when the new one takes
- " ownership, but kill it to be sure we don't fill up the job table.
- call jobstop(s:selections[a:reg].owner)
+ let prev_job = s:selections[a:reg].owner
end
let s:selections[a:reg] = copy(s:selection)
let selection = s:selections[a:reg]
@@ -175,13 +173,23 @@ function! s:clipboard.set(lines, regtype, reg) abort
call jobsend(jobid, a:lines)
call jobclose(jobid, 'stdin')
let selection.owner = jobid
+ let ret = 1
else
echohl WarningMsg
echomsg 'clipboard: failed to execute: '.(s:copy[a:reg])
echohl None
- return 0
+ let ret = 1
+ endif
+
+ " The previous provider instance should exit when the new one takes
+ " ownership, but kill it to be sure we don't fill up the job table.
+ if exists('prev_job')
+ call timer_start(1000, {... ->
+ \ jobwait([prev_job], 0)[0] == -1
+ \ && jobstop(prev_job)})
endif
- return 1
+
+ return ret
endfunction
function! provider#clipboard#Call(method, args) abort
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 0f345df22b..18043bf710 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9181,7 +9181,7 @@ makeopens(
// Take care of tab-local working directories if applicable
if (tp->tp_localdir) {
- if (fputs("if has('nvim') | tcd ", fd) < 0
+ if (fputs("if exists(':tcd') == 2 | tcd ", fd) < 0
|| ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
|| fputs(" | endif", fd) < 0
|| put_eol(fd) == FAIL) {
diff --git a/src/nvim/testdir/load.vim b/src/nvim/testdir/load.vim
index 6369b8f45e..5697ee7304 100644
--- a/src/nvim/testdir/load.vim
+++ b/src/nvim/testdir/load.vim
@@ -6,8 +6,8 @@ function! s:load_factor() abort
for _ in range(5)
let g:val = 0
- call timer_start(timeout, {-> nvim_set_var('val', 1)})
let start = reltime()
+ call timer_start(timeout, {-> nvim_set_var('val', 1)})
while 1
sleep 10m
if g:val == 1
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim
index c8161b1f9b..5c62538b7d 100644
--- a/src/nvim/testdir/runtest.vim
+++ b/src/nvim/testdir/runtest.vim
@@ -57,6 +57,19 @@ else
set encoding=latin1
endif
+" REDIR_TEST_TO_NULL has a very permissive SwapExists autocommand which is for
+" the test_name.vim file itself. Replace it here with a more restrictive one,
+" so we still catch mistakes.
+let s:test_script_fname = expand('%')
+au! SwapExists * call HandleSwapExists()
+func HandleSwapExists()
+ " Only ignore finding a swap file for the test script (the user might be
+ " editing it and do ":make test_name") and the output file.
+ if expand('<afile>') == 'messages' || expand('<afile>') =~ s:test_script_fname
+ let v:swapchoice = 'e'
+ endif
+endfunc
+
" Avoid stopping at the "hit enter" prompt
set nomore
@@ -150,6 +163,7 @@ func RunTheTest(test)
" Clear any autocommands
au!
+ au SwapExists * call HandleSwapExists()
" Close any extra tab pages and windows and make the current one not modified.
while tabpagenr('$') > 1
@@ -269,7 +283,6 @@ let s:flaky_tests = [
\ 'Test_oneshot()',
\ 'Test_out_cb()',
\ 'Test_paused()',
- \ 'Test_popup_and_window_resize()',
\ 'Test_quoteplus()',
\ 'Test_quotestar()',
\ 'Test_reltime()',
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index 6cc2d06a36..ab0a4fd706 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -196,16 +196,26 @@ func s:feedkeys(timer)
call feedkeys('x', 'nt')
endfunc
+" Get $VIMPROG to run Vim executable.
+" The Makefile writes it as the first line in the "vimcmd" file.
+" Nvim: uses $NVIM_TEST_ARG0.
+func GetVimProg()
+ if empty($NVIM_TEST_ARG0)
+ " Assume the script was sourced instead of running "make".
+ return '../../../build/bin/nvim'
+ endif
+ return $NVIM_TEST_ARG0
+endfunc
+
" Get the command to run Vim, with -u NONE and --headless arguments.
" If there is an argument use it instead of "NONE".
-" Returns an empty string on error.
func GetVimCommand(...)
if a:0 == 0
let name = 'NONE'
else
let name = a:1
endif
- let cmd = v:progpath
+ let cmd = GetVimProg()
let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '')
if cmd !~ '-u '. name
let cmd = cmd . ' -u ' . name
@@ -215,6 +225,14 @@ func GetVimCommand(...)
return cmd
endfunc
+" Get the command to run Vim, with --clean.
+func GetVimCommandClean()
+ let cmd = GetVimCommand()
+ let cmd = substitute(cmd, '-u NONE', '--clean', '')
+ let cmd = substitute(cmd, '--headless', '', '')
+ return cmd
+endfunc
+
" Run Vim, using the "vimcmd" file and "-u NORC".
" "before" is a list of Vim commands to be executed before loading plugins.
" "after" is a list of Vim commands to be executed after loading plugins.
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 7d844e055c..0027a0a52e 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -669,10 +669,10 @@ func Test_popup_and_window_resize()
if h < 15
return
endif
- let g:buf = term_start([$NVIM_PRG, '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3})
- call term_sendkeys(g:buf, (h / 3 - 1)."o\<esc>G")
- call term_sendkeys(g:buf, "i\<c-x>")
+ let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3})
+ call term_sendkeys(g:buf, (h / 3 - 1)."o\<esc>")
call term_wait(g:buf, 200)
+ call term_sendkeys(g:buf, "Gi\<c-x>")
call term_sendkeys(g:buf, "\<c-v>")
call term_wait(g:buf, 100)
" popup first entry "!" must be at the top
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index a3de879b2a..f75c295a1e 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -470,7 +470,7 @@ func Test_bg_detection()
hi Normal ctermbg=NONE
endfunc
-fun Test_synstack_synIDtrans()
+func Test_synstack_synIDtrans()
new
setfiletype c
syntax on
@@ -494,6 +494,39 @@ fun Test_synstack_synIDtrans()
bw!
endfunc
+" Check highlighting for a small piece of C code with a screen dump.
+func Test_syntax_c()
+ if !has('terminal')
+ return
+ endif
+ call writefile([
+ \ '/* comment line at the top */',
+ \ ' int',
+ \ 'main(int argc, char **argv)// another comment',
+ \ '{',
+ \ '#if 0',
+ \ ' int not_used;',
+ \ '#else',
+ \ ' int used;',
+ \ '#endif',
+ \ ' printf("Just an example piece of C code\n");',
+ \ ' return 0x0ff;',
+ \ '}',
+ \ ' static void',
+ \ 'myFunction(const double count, struct nothing, long there) {',
+ \ ' // 123: nothing to read here',
+ \ ' for (int i = 0; i < count; ++i) {',
+ \ ' break;',
+ \ ' }',
+ \ '}',
+ \ ], 'Xtest.c')
+ let buf = RunVimInTerminal('Xtest.c', {})
+ call VerifyScreenDump(buf, 'Test_syntax_c_01')
+ call StopVimInTerminal(buf)
+
+ call delete('Xtest.c')
+endfun
+
" Using \z() in a region with NFA failing should not crash.
func Test_syn_wrong_z_one()
new
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 180ed9aa02..a1d9f50720 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -707,11 +707,10 @@ describe('jobs', function()
it('will return -1 if the wait timed out', function()
source([[
call rpcnotify(g:channel, 'wait', jobwait([
- \ jobstart('exit 4'),
\ jobstart((has('win32') ? 'Start-Sleep 10' : 'sleep 10').'; exit 5'),
- \ ], has('win32') ? 6000 : 100))
+ \ ], 100))
]])
- eq({'notification', 'wait', {{4, -1}}}, next_msg())
+ eq({'notification', 'wait', {{-1}}}, next_msg())
end)
it('can pass 0 to check if a job exists', function()
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua
index cd099e30ed..e4fb642d6a 100644
--- a/test/functional/eval/timer_spec.lua
+++ b/test/functional/eval/timer_spec.lua
@@ -164,8 +164,7 @@ describe('timers', function()
]])
command("call timer_start(10, 'MyHandler', {'repeat': -1})")
eq(0,eval("g:val"))
- run(nil, nil, nil, load_adjust(50))
- retry(nil, 5000, function()
+ retry(nil, nil, function()
eq(3, eval("g:val"))
end)
end)