aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.builds/freebsd.yml1
-rw-r--r--ci/build.ps120
-rw-r--r--cmake/RunTests.cmake4
-rw-r--r--runtime/doc/autocmd.txt16
-rw-r--r--runtime/doc/diagnostic.txt10
-rw-r--r--runtime/doc/map.txt4
-rw-r--r--runtime/doc/vim_diff.txt4
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua6
-rw-r--r--runtime/lua/vim/lsp/util.lua2
-rw-r--r--src/nvim/api/autocmd.c16
-rw-r--r--src/nvim/autocmd.c3
-rw-r--r--src/nvim/eval/typval.c21
-rw-r--r--src/nvim/getchar.c7
-rw-r--r--src/nvim/os/pty_process_win.c2
-rw-r--r--src/nvim/testdir/test_alot.vim39
-rw-r--r--src/nvim/testdir/test_delete.vim114
-rw-r--r--src/nvim/testdir/test_file_perm.vim30
-rw-r--r--src/nvim/testdir/test_mapping.vim30
-rw-r--r--src/nvim/testdir/test_searchpos.vim30
-rw-r--r--src/nvim/testdir/test_set.vim29
-rw-r--r--src/nvim/testdir/test_sort.vim1
-rw-r--r--test/functional/api/buffer_updates_spec.lua5
-rw-r--r--test/functional/api/keymap_spec.lua18
-rw-r--r--test/functional/ex_cmds/map_spec.lua21
-rw-r--r--test/functional/legacy/delete_spec.lua43
-rw-r--r--test/functional/legacy/file_perm_spec.lua43
-rw-r--r--test/functional/legacy/searchpos_spec.lua35
-rw-r--r--test/functional/legacy/set_spec.lua30
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua1
-rw-r--r--test/functional/terminal/helpers.lua2
-rw-r--r--test/functional/ui/popupmenu_spec.lua2
-rw-r--r--test/functional/ui/screen.lua10
32 files changed, 316 insertions, 283 deletions
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index d5809c42cf..8596eb2a7f 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -5,7 +5,6 @@ packages:
- gmake
- ninja
- libtool
-- sha
- automake
- pkgconf
- unzip
diff --git a/ci/build.ps1 b/ci/build.ps1
index 01579a96fe..c7c3b3d470 100644
--- a/ci/build.ps1
+++ b/ci/build.ps1
@@ -164,21 +164,17 @@ if (-not $NoTests) {
exit $LastExitCode
}
- # FIXME: These tests freezes on github CI and causes all jobs to fail.
- # Comment out until this is fixed.
-
# Old tests
# Add MSYS to path, required for e.g. `find` used in test scripts.
# But would break functionaltests, where its `more` would be used then.
-
- # $OldPath = $env:PATH
- # $env:PATH = "C:\msys64\usr\bin;$env:PATH"
- # & "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1 ; exitIfFailed
- # $env:PATH = $OldPath
-
- # if ($uploadToCodecov) {
- # bash -l /c/projects/neovim/ci/common/submit_coverage.sh oldtest
- # }
+ $OldPath = $env:PATH
+ $env:PATH = "C:\msys64\usr\bin;$env:PATH"
+ & "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1 ; exitIfFailed
+ $env:PATH = $OldPath
+
+ if ($uploadToCodecov) {
+ bash -l /c/projects/neovim/ci/common/submit_coverage.sh oldtest
+ }
}
# Ensure choco's cpack is not in PATH otherwise, it conflicts with CMake's
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index 789131c26c..3adbcbbfc5 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -95,7 +95,5 @@ if(NOT res EQUAL 0)
endif()
endif()
- IF (NOT WIN32)
- message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
- ENDIF()
+ message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
endif()
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 9054bedc8d..4b8c07fde4 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -674,15 +674,19 @@ FuncUndefined When a user function is used but it isn't
alternative is to use an autoloaded function.
See |autoload-functions|.
*UIEnter*
-UIEnter After a UI connects via |nvim_ui_attach()|,
- after VimEnter. Can be used for GUI-specific
- configuration.
+UIEnter After a UI connects via |nvim_ui_attach()|, or
+ after builtin TUI is started, after |VimEnter|.
Sets these |v:event| keys:
- chan
+ chan: 0 for builtin TUI
+ 1 for |--embed|
+ |channel-id| of the UI otherwise
*UILeave*
-UILeave After a UI disconnects from Nvim.
+UILeave After a UI disconnects from Nvim, or after
+ builtin TUI is stopped, after |VimLeave|.
Sets these |v:event| keys:
- chan
+ chan: 0 for builtin TUI
+ 1 for |--embed|
+ |channel-id| of the UI otherwise
*InsertChange*
InsertChange When typing <Insert> while in Insert or
Replace mode. The |v:insertmode| variable
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index 19db3158be..781539cfb6 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -39,16 +39,18 @@ modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it
requires a namespace.
*diagnostic-structure*
-A diagnostic is a Lua table with the following keys:
+A diagnostic is a Lua table with the following keys. Required keys are
+indicated with (*):
bufnr: Buffer number
- lnum: The starting line of the diagnostic
+ lnum(*): The starting line of the diagnostic
end_lnum: The final line of the diagnostic
- col: The starting column of the diagnostic
+ col(*): The starting column of the diagnostic
end_col: The final column of the diagnostic
severity: The severity of the diagnostic |vim.diagnostic.severity|
- message: The diagnostic text
+ message(*): The diagnostic text
source: The source of the diagnostic
+ code: The diagnostic code
user_data: Arbitrary data plugins or users can add
Diagnostics use the same indexing as the rest of the Nvim API (i.e. 0-based
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 8715c3231c..b874d6dc61 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -65,8 +65,8 @@ modes.
where the map command applies. Disallow mapping of
{rhs}, to avoid nested and recursive mappings. Often
used to redefine a command.
- Note: A mapping whose {lhs} starts with <Plug> is
- always applied even if mapping is disallowed.
+ Note: When <Plug> appears in the {rhs} this part is
+ always applied even if remapping is disallowed.
:unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap*
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 90f56e2566..5ea6a9c5dd 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -358,10 +358,6 @@ Macro/|recording| behavior
macros and 'keymap' at the same time. This also means you can use |:imap| on
the results of keys from 'keymap'.
-Mappings:
-- A mapping whose {lhs} starts with <Plug> is always applied even if mapping
- is disallowed by |nore|.
-
Motion:
The |jumplist| avoids useless/phantom jumps.
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 68942ae11a..614d83f565 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -104,8 +104,10 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
severity = severity_lsp_to_vim(diagnostic.severity),
message = diagnostic.message,
source = diagnostic.source,
+ code = diagnostic.code,
user_data = {
lsp = {
+ -- usage of user_data.lsp.code is deprecated in favor of the top-level code field
code = diagnostic.code,
codeDescription = diagnostic.codeDescription,
tags = diagnostic.tags,
@@ -120,7 +122,8 @@ end
---@private
local function diagnostic_vim_to_lsp(diagnostics)
return vim.tbl_map(function(diagnostic)
- return vim.tbl_extend("error", {
+ return vim.tbl_extend("keep", {
+ -- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp
range = {
start = {
line = diagnostic.lnum,
@@ -134,6 +137,7 @@ local function diagnostic_vim_to_lsp(diagnostics)
severity = severity_vim_to_lsp(diagnostic.severity),
message = diagnostic.message,
source = diagnostic.source,
+ code = diagnostic.code,
}, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {})
end, diagnostics)
end
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 655c3a4679..59ab3d7e1f 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -480,7 +480,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
-- Remove final line if needed
local fix_eol = has_eol_text_edit
- fix_eol = fix_eol and api.nvim_buf_get_option(bufnr, 'fixeol')
+ fix_eol = fix_eol and (api.nvim_buf_get_option(bufnr, 'eol') or (api.nvim_buf_get_option(bufnr, 'fixeol') and not api.nvim_buf_get_option('binary')))
fix_eol = fix_eol and get_line(bufnr, max - 1) == ''
if fix_eol then
vim.api.nvim_buf_set_lines(bufnr, -2, -1, false, {})
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index ad0e78cb50..0ad7b320d0 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -1,3 +1,6 @@
+// This is an open source non-commercial project. Dear PVS-Studio, please check
+// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+
#include <stdbool.h>
#include <stdio.h>
@@ -128,10 +131,8 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Error *err)
continue;
}
- for (AutoPat *ap = au_get_autopat_for_event(event);
- ap != NULL;
- ap = ap->next) {
- if (ap == NULL || ap->cmds == NULL) {
+ for (AutoPat *ap = au_get_autopat_for_event(event); ap != NULL; ap = ap->next) {
+ if (ap->cmds == NULL) {
continue;
}
@@ -423,13 +424,6 @@ Integer nvim_create_autocmd(uint64_t channel_id, Object event, Dict(create_autoc
ADD(patterns, STRING_OBJ(cstr_to_string((char *)pattern_buflocal)));
}
- if (aucmd.type == CALLABLE_NONE) {
- api_set_error(err,
- kErrorTypeValidation,
- "'command' or 'callback' is required");
- goto cleanup;
- }
-
if (opts->desc.type != kObjectTypeNil) {
if (opts->desc.type == kObjectTypeString) {
desc = opts->desc.data.string.data;
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 66222f6a6a..e7e1d5fd1b 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -887,7 +887,6 @@ int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, char_u *
while (patlen) {
// detect special <buffer[=X]> buffer-local patterns
is_buflocal = aupat_is_buflocal(pat, patlen);
- buflocal_nr = 0;
if (is_buflocal) {
buflocal_nr = aupat_get_buflocal_nr(pat, patlen);
@@ -2474,7 +2473,7 @@ bool aucmd_exec_is_deleted(AucmdExecutable acc)
case CALLABLE_EX:
return acc.callable.cmd == NULL;
case CALLABLE_CB:
- return callback_is_freed(acc.callable.cb);
+ return acc.callable.cb.type == kCallbackNone;
case CALLABLE_NONE:
return true;
}
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 44b003d106..d492c67877 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1155,27 +1155,6 @@ void callback_free(Callback *callback)
callback->data.funcref = NULL;
}
-/// Check if callback is freed
-bool callback_is_freed(Callback callback)
-{
- switch (callback.type) {
- case kCallbackFuncref:
- return false;
- break;
- case kCallbackPartial:
- return false;
- break;
- case kCallbackLua:
- return callback.data.luaref == LUA_NOREF;
- break;
- case kCallbackNone:
- return true;
- break;
- }
-
- return true;
-}
-
/// Copy a callback into a typval_T.
void callback_put(Callback *cb, typval_T *tv)
FUNC_ATTR_NONNULL_ALL
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 85a5c176bb..8426cdb98c 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1712,11 +1712,10 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
int local_State = get_real_state();
bool is_plug_map = false;
- // Check if typehead starts with a <Plug> mapping.
- // In that case we will ignore nore flag on it.
+ // If typehead starts with <Plug> then remap, even for a "noremap" mapping.
if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
- && typebuf.tb_buf[typebuf.tb_off+1] == KS_EXTRA
- && typebuf.tb_buf[typebuf.tb_off+2] == KE_PLUG) {
+ && typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
+ && typebuf.tb_buf[typebuf.tb_off + 2] == KE_PLUG) {
is_plug_map = true;
}
diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c
index f78f3e66f5..99231968a2 100644
--- a/src/nvim/os/pty_process_win.c
+++ b/src/nvim/os/pty_process_win.c
@@ -281,7 +281,7 @@ static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer)
PtyProcess *ptyproc = wait_eof_timer->data;
Process *proc = (Process *)ptyproc;
- if (proc->out.closed || !uv_is_readable(proc->out.uvstream)) {
+ if (proc->out.closed || proc->out.did_eof || !uv_is_readable(proc->out.uvstream)) {
uv_timer_stop(&ptyproc->wait_eof_timer);
pty_process_finish2(ptyproc);
}
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index 5a3d1d56bb..bb744f7b41 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -3,56 +3,33 @@
source test_backup.vim
source test_behave.vim
-source test_cd.vim
-source test_changedtick.vim
source test_compiler.vim
-source test_cursor_func.vim
-source test_cursorline.vim
source test_ex_equal.vim
source test_ex_undo.vim
source test_ex_z.vim
source test_ex_mode.vim
-source test_execute_func.vim
+source test_expand.vim
source test_expand_func.vim
source test_feedkeys.vim
-source test_filter_cmd.vim
-source test_filter_map.vim
-source test_findfile.vim
-source test_float_func.vim
-source test_functions.vim
+source test_file_perm.vim
+source test_fnamemodify.vim
source test_ga.vim
+source test_glob2regpat.vim
source test_global.vim
-source test_goto.vim
-source test_join.vim
source test_jumps.vim
-source test_fileformat.vim
-source test_filetype.vim
-source test_filetype_lua.vim
-source test_lambda.vim
+source test_lispwords.vim
source test_menu.vim
-source test_messages.vim
-source test_modeline.vim
source test_move.vim
-source test_partial.vim
-source test_popup.vim
source test_put.vim
-source test_rename.vim
+source test_reltime.vim
source test_scroll_opt.vim
+source test_searchpos.vim
+source test_set.vim
source test_shift.vim
-" Test fails on windows CI when using the MSVC compiler.
-" source test_sort.vim
source test_sha256.vim
-source test_suspend.vim
-source test_syn_attr.vim
source test_tabline.vim
-source test_tabpage.vim
source test_tagcase.vim
source test_tagfunc.vim
-source test_tagjump.vim
-source test_taglist.vim
-source test_true_false.vim
source test_unlet.vim
source test_version.vim
-source test_virtualedit.vim
-source test_window_cmd.vim
source test_wnext.vim
diff --git a/src/nvim/testdir/test_delete.vim b/src/nvim/testdir/test_delete.vim
new file mode 100644
index 0000000000..b23a3bd025
--- /dev/null
+++ b/src/nvim/testdir/test_delete.vim
@@ -0,0 +1,114 @@
+" Test for delete().
+
+func Test_file_delete()
+ split Xfile
+ call setline(1, ['a', 'b'])
+ wq
+ call assert_equal(['a', 'b'], readfile('Xfile'))
+ call assert_equal(0, delete('Xfile'))
+ call assert_fails('call readfile("Xfile")', 'E484:')
+ call assert_equal(-1, delete('Xfile'))
+ bwipe Xfile
+endfunc
+
+func Test_dir_delete()
+ call mkdir('Xdir1')
+ call assert_true(isdirectory('Xdir1'))
+ call assert_equal(0, delete('Xdir1', 'd'))
+ call assert_false(isdirectory('Xdir1'))
+ call assert_equal(-1, delete('Xdir1', 'd'))
+endfunc
+
+func Test_recursive_delete()
+ call mkdir('Xdir1')
+ call mkdir('Xdir1/subdir')
+ call mkdir('Xdir1/empty')
+ split Xdir1/Xfile
+ call setline(1, ['a', 'b'])
+ w
+ w Xdir1/subdir/Xfile
+ close
+ call assert_true(isdirectory('Xdir1'))
+ call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
+ call assert_true(isdirectory('Xdir1/subdir'))
+ call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
+ call assert_true('Xdir1/empty'->isdirectory())
+ call assert_equal(0, delete('Xdir1', 'rf'))
+ call assert_false(isdirectory('Xdir1'))
+ call assert_equal(-1, delete('Xdir1', 'd'))
+ bwipe Xdir1/Xfile
+ bwipe Xdir1/subdir/Xfile
+endfunc
+
+func Test_symlink_delete()
+ if !has('unix')
+ return
+ endif
+ split Xfile
+ call setline(1, ['a', 'b'])
+ wq
+ silent !ln -s Xfile Xlink
+ " Delete the link, not the file
+ call assert_equal(0, delete('Xlink'))
+ call assert_equal(-1, delete('Xlink'))
+ call assert_equal(0, delete('Xfile'))
+ bwipe Xfile
+endfunc
+
+func Test_symlink_dir_delete()
+ if !has('unix')
+ return
+ endif
+ call mkdir('Xdir1')
+ silent !ln -s Xdir1 Xlink
+ call assert_true(isdirectory('Xdir1'))
+ call assert_true(isdirectory('Xlink'))
+ " Delete the link, not the directory
+ call assert_equal(0, delete('Xlink'))
+ call assert_equal(-1, delete('Xlink'))
+ call assert_equal(0, delete('Xdir1', 'd'))
+endfunc
+
+func Test_symlink_recursive_delete()
+ if !has('unix')
+ return
+ endif
+ call mkdir('Xdir3')
+ call mkdir('Xdir3/subdir')
+ call mkdir('Xdir4')
+ split Xdir3/Xfile
+ call setline(1, ['a', 'b'])
+ w
+ w Xdir3/subdir/Xfile
+ w Xdir4/Xfile
+ close
+ silent !ln -s ../Xdir4 Xdir3/Xlink
+
+ call assert_true(isdirectory('Xdir3'))
+ call assert_equal(['a', 'b'], readfile('Xdir3/Xfile'))
+ call assert_true(isdirectory('Xdir3/subdir'))
+ call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile'))
+ call assert_true(isdirectory('Xdir4'))
+ call assert_true(isdirectory('Xdir3/Xlink'))
+ call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
+
+ call assert_equal(0, delete('Xdir3', 'rf'))
+ call assert_false(isdirectory('Xdir3'))
+ call assert_equal(-1, delete('Xdir3', 'd'))
+ " symlink is deleted, not the directory it points to
+ call assert_true(isdirectory('Xdir4'))
+ call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
+ call assert_equal(0, delete('Xdir4/Xfile'))
+ call assert_equal(0, delete('Xdir4', 'd'))
+
+ bwipe Xdir3/Xfile
+ bwipe Xdir3/subdir/Xfile
+ bwipe Xdir4/Xfile
+endfunc
+
+func Test_delete_errors()
+ call assert_fails('call delete('''')', 'E474:')
+ call assert_fails('call delete(''foo'', 0)', 'E15:')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_file_perm.vim b/src/nvim/testdir/test_file_perm.vim
new file mode 100644
index 0000000000..1cb09e8647
--- /dev/null
+++ b/src/nvim/testdir/test_file_perm.vim
@@ -0,0 +1,30 @@
+" Test getting and setting file permissions.
+
+func Test_file_perm()
+ call assert_equal('', getfperm('Xtest'))
+ call assert_equal(0, 'Xtest'->setfperm('r--------'))
+
+ call writefile(['one'], 'Xtest')
+ call assert_true(len('Xtest'->getfperm()) == 9)
+
+ call assert_equal(1, setfperm('Xtest', 'rwx------'))
+ if has('win32')
+ call assert_equal('rw-rw-rw-', getfperm('Xtest'))
+ else
+ call assert_equal('rwx------', getfperm('Xtest'))
+ endif
+
+ call assert_equal(1, setfperm('Xtest', 'r--r--r--'))
+ call assert_equal('r--r--r--', getfperm('Xtest'))
+
+ call assert_fails("setfperm('Xtest', '---')")
+
+ call assert_equal(1, setfperm('Xtest', 'rwx------'))
+ call delete('Xtest')
+
+ call assert_fails("call setfperm(['Xfile'], 'rw-rw-rw-')", 'E730:')
+ call assert_fails("call setfperm('Xfile', [])", 'E730:')
+ call assert_fails("call setfperm('Xfile', 'rwxrwxrwxrw')", 'E475:')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index 1080a3c85b..98440ccdd7 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -646,4 +646,34 @@ func Test_abbreviate_multi_byte()
bwipe!
endfunc
+" Test for <Plug> always being mapped, even when used with "noremap".
+func Test_plug_remap()
+ let g:foo = 0
+ nnoremap <Plug>(Increase_x) <Cmd>let g:foo += 1<CR>
+ nmap <F2> <Plug>(Increase_x)
+ nnoremap <F3> <Plug>(Increase_x)
+ call feedkeys("\<F2>", 'xt')
+ call assert_equal(1, g:foo)
+ call feedkeys("\<F3>", 'xt')
+ call assert_equal(2, g:foo)
+ nnoremap x <Nop>
+ nmap <F4> x<Plug>(Increase_x)x
+ nnoremap <F5> x<Plug>(Increase_x)x
+ call setline(1, 'Some text')
+ normal! gg$
+ call feedkeys("\<F4>", 'xt')
+ call assert_equal(3, g:foo)
+ call assert_equal('Some text', getline(1))
+ call feedkeys("\<F5>", 'xt')
+ call assert_equal(4, g:foo)
+ call assert_equal('Some te', getline(1))
+ nunmap <Plug>(Increase_x)
+ nunmap <F2>
+ nunmap <F3>
+ nunmap <F4>
+ nunmap <F5>
+ unlet g:foo
+ %bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_searchpos.vim b/src/nvim/testdir/test_searchpos.vim
new file mode 100644
index 0000000000..dd13c305c5
--- /dev/null
+++ b/src/nvim/testdir/test_searchpos.vim
@@ -0,0 +1,30 @@
+" Tests for searchpos()
+
+func Test_searchpos()
+ new one
+ 0put ='1a3'
+ 1put ='123xyz'
+ call cursor(1, 1)
+ call assert_equal([1, 1, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
+ call cursor(1, 2)
+ call assert_equal([2, 1, 1], '\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW'))
+ set cpo-=c
+ call cursor(1, 2)
+ call assert_equal([1, 2, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
+ call cursor(1, 3)
+ call assert_equal([1, 3, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
+
+ " Now with \zs, first match is in column 0, "a" is matched.
+ call cursor(1, 3)
+ call assert_equal([2, 4, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW'))
+ " With z flag start at cursor column, don't see the "a".
+ call cursor(1, 3)
+ call assert_equal([2, 4, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz'))
+
+ set cpo+=c
+ " close the window
+ q!
+
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_set.vim b/src/nvim/testdir/test_set.vim
new file mode 100644
index 0000000000..2b1e9eeee0
--- /dev/null
+++ b/src/nvim/testdir/test_set.vim
@@ -0,0 +1,29 @@
+" Tests for the :set command
+
+function Test_set_backslash()
+ let isk_save = &isk
+
+ set isk=a,b,c
+ set isk+=d
+ call assert_equal('a,b,c,d', &isk)
+ set isk+=\\,e
+ call assert_equal('a,b,c,d,\,e', &isk)
+ set isk-=e
+ call assert_equal('a,b,c,d,\', &isk)
+ set isk-=\\
+ call assert_equal('a,b,c,d', &isk)
+
+ let &isk = isk_save
+endfunction
+
+function Test_set_add()
+ let wig_save = &wig
+
+ set wildignore=*.png,
+ set wildignore+=*.jpg
+ call assert_equal('*.png,*.jpg', &wig)
+
+ let &wig = wig_save
+endfunction
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim
index 570c4415c6..f72368fc59 100644
--- a/src/nvim/testdir/test_sort.vim
+++ b/src/nvim/testdir/test_sort.vim
@@ -12,6 +12,7 @@ func Compare2(a, b) abort
endfunc
func Test_sort_strings()
+ CheckNotMSWindows " FIXME: Why does this fail with MSVC?
" numbers compared as strings
call assert_equal([1, 2, 3], sort([3, 2, 1]))
call assert_equal([13, 28, 3], sort([3, 28, 13]))
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index e9ad756947..fc09e4cde0 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -7,7 +7,6 @@ local nvim_prog = helpers.nvim_prog
local pcall_err = helpers.pcall_err
local sleep = helpers.sleep
local write_file = helpers.write_file
-local iswin = helpers.iswin
local origlines = {"original line 1",
"original line 2",
@@ -824,11 +823,11 @@ describe('API: buffer events:', function()
end
msg = next_msg()
end
- -- FIXME: Windows
- assert(iswin(), 'did not match/receive expected nvim_buf_lines_event lines')
+ assert(false, 'did not match/receive expected nvim_buf_lines_event lines')
end
it('when :terminal lines change', function()
+ if helpers.pending_win32(pending) then return end
local buffer_lines = {}
local expected_lines = {}
command('terminal "'..nvim_prog..'" -u NONE -i NONE -n -c "set shortmess+=A"')
diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua
index 6562b40d53..c0edcde476 100644
--- a/test/functional/api/keymap_spec.lua
+++ b/test/functional/api/keymap_spec.lua
@@ -880,24 +880,6 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
eq("\nn lhs rhs\n map description",
helpers.exec_capture("nmap lhs"))
end)
-
- it ('can :filter maps based on description', function()
- meths.set_keymap('n', 'asdf1', 'qwert', {desc='do the one thing'})
- meths.set_keymap('n', 'asdf2', 'qwert', {desc='doesnot really do anything'})
- meths.set_keymap('n', 'asdf3', 'qwert', {desc='do the other thing'})
- eq([[
-
-n asdf3 qwert
- do the other thing
-n asdf1 qwert
- do the one thing]],
- helpers.exec_capture('filter the nmap'))
- end)
-
- it ('shows <nop> as map rhs', function()
- meths.set_keymap('n', 'asdf', '<nop>', {})
- eq('\nn asdf <Nop>', helpers.exec_capture('nmap asdf'))
- end)
end)
describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua
index 6eeb079f75..eae36b9ae9 100644
--- a/test/functional/ex_cmds/map_spec.lua
+++ b/test/functional/ex_cmds/map_spec.lua
@@ -30,6 +30,27 @@ describe(':*map', function()
expect('-foo-')
end)
+ it('shows <nop> as mapping rhs', function()
+ command('nmap asdf <Nop>')
+ eq([[
+
+n asdf <Nop>]],
+ helpers.exec_capture('nmap asdf'))
+ end)
+
+ it('mappings with description can be filtered', function()
+ meths.set_keymap('n', 'asdf1', 'qwert', {desc='do the one thing'})
+ meths.set_keymap('n', 'asdf2', 'qwert', {desc='doesnot really do anything'})
+ meths.set_keymap('n', 'asdf3', 'qwert', {desc='do the other thing'})
+ eq([[
+
+n asdf3 qwert
+ do the other thing
+n asdf1 qwert
+ do the one thing]],
+ helpers.exec_capture('filter the nmap'))
+ end)
+
it('<Plug> mappings ignore nore', function()
command('let x = 0')
eq(0, meths.eval('x'))
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua
index 141d9583e6..623b6b14a5 100644
--- a/test/functional/legacy/delete_spec.lua
+++ b/test/functional/legacy/delete_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local eq, eval, command = helpers.eq, helpers.eval, helpers.command
-local exc_exec = helpers.exc_exec
describe('Test for delete()', function()
before_each(clear)
@@ -9,42 +8,6 @@ describe('Test for delete()', function()
os.remove('Xfile')
end)
- it('file delete', function()
- command('split Xfile')
- command("call setline(1, ['a', 'b'])")
- command('wq')
- eq(eval("['a', 'b']"), eval("readfile('Xfile')"))
- eq(0, eval("delete('Xfile')"))
- eq(-1, eval("delete('Xfile')"))
- end)
-
- it('directory delete', function()
- command("call mkdir('Xdir1')")
- eq(1, eval("isdirectory('Xdir1')"))
- eq(0, eval("delete('Xdir1', 'd')"))
- eq(0, eval("isdirectory('Xdir1')"))
- eq(-1, eval("delete('Xdir1', 'd')"))
- end)
- it('recursive delete', function()
- command("call mkdir('Xdir1')")
- command("call mkdir('Xdir1/subdir')")
- command("call mkdir('Xdir1/empty')")
- command('split Xdir1/Xfile')
- command("call setline(1, ['a', 'b'])")
- command('w')
- command('w Xdir1/subdir/Xfile')
- command('close')
-
- eq(1, eval("isdirectory('Xdir1')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')"))
- eq(1, eval("isdirectory('Xdir1/subdir')"))
- eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')"))
- eq(1, eval("'Xdir1/empty'->isdirectory()"))
- eq(0, eval("delete('Xdir1', 'rf')"))
- eq(0, eval("isdirectory('Xdir1')"))
- eq(-1, eval("delete('Xdir1', 'd')"))
- end)
-
it('symlink delete', function()
source([[
split Xfile
@@ -115,10 +78,4 @@ describe('Test for delete()', function()
eq(0, eval("delete('Xdir4/Xfile')"))
eq(0, eval("delete('Xdir4', 'd')"))
end)
-
- it('gives correct emsgs', function()
- eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')"))
- eq('Vim(call):E15: Invalid expression: 0',
- exc_exec("call delete('foo', 0)"))
- end)
end)
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua
deleted file mode 100644
index ccdbfe0534..0000000000
--- a/test/functional/legacy/file_perm_spec.lua
+++ /dev/null
@@ -1,43 +0,0 @@
--- Test getting and setting file permissions.
-require('os')
-
-local helpers = require('test.functional.helpers')(after_each)
-local clear, call, eq = helpers.clear, helpers.call, helpers.eq
-local neq, exc_exec, eval = helpers.neq, helpers.exc_exec, helpers.eval
-
-describe('Test getting and setting file permissions', function()
- local tempfile = helpers.tmpname()
-
- before_each(function()
- os.remove(tempfile)
- clear()
- end)
-
- it('file permissions', function()
- -- eval() is used to test VimL method syntax for setfperm() and getfperm()
- eq('', call('getfperm', tempfile))
- eq(0, eval("'" .. tempfile .. "'->setfperm('r--------')"))
-
- call('writefile', {'one'}, tempfile)
- eq(9, eval("len('" .. tempfile .. "'->getfperm())"))
-
- eq(1, call('setfperm', tempfile, 'rwx------'))
- if helpers.is_os('win') then
- eq('rw-rw-rw-', call('getfperm', tempfile))
- else
- eq('rwx------', call('getfperm', tempfile))
- end
-
- eq(1, call('setfperm', tempfile, 'r--r--r--'))
- eq('r--r--r--', call('getfperm', tempfile))
-
- local err = exc_exec(('call setfperm("%s", "---")'):format(tempfile))
- neq(err:find('E475:'), nil)
-
- eq(1, call('setfperm', tempfile, 'rwx------'))
- end)
-
- after_each(function()
- os.remove(tempfile)
- end)
-end)
diff --git a/test/functional/legacy/searchpos_spec.lua b/test/functional/legacy/searchpos_spec.lua
deleted file mode 100644
index fc18341c38..0000000000
--- a/test/functional/legacy/searchpos_spec.lua
+++ /dev/null
@@ -1,35 +0,0 @@
-local helpers = require('test.functional.helpers')(after_each)
-local call = helpers.call
-local clear = helpers.clear
-local command = helpers.command
-local eq = helpers.eq
-local eval = helpers.eval
-local insert = helpers.insert
-
-describe('searchpos', function()
- before_each(clear)
-
- it('is working', function()
- insert([[
- 1a3
- 123xyz]])
-
- call('cursor', 1, 1)
- eq({1, 1, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
- call('cursor', 1, 2)
- eq({2, 1, 1}, eval([['\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW')]]))
-
- command('set cpo-=c')
- call('cursor', 1, 2)
- eq({1, 2, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
- call('cursor', 1, 3)
- eq({1, 3, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')]]))
-
- -- Now with \zs, first match is in column 0, "a" is matched.
- call('cursor', 1, 3)
- eq({2, 4, 2}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')]]))
- -- With z flag start at cursor column, don't see the "a".
- call('cursor', 1, 3)
- eq({2, 4, 1}, eval([[searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')]]))
- end)
-end)
diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua
deleted file mode 100644
index deb268b1e8..0000000000
--- a/test/functional/legacy/set_spec.lua
+++ /dev/null
@@ -1,30 +0,0 @@
--- Tests for :set
-
-local helpers = require('test.functional.helpers')(after_each)
-local clear, command, eval, eq =
- helpers.clear, helpers.command, helpers.eval, helpers.eq
-
-describe(':set', function()
- before_each(clear)
-
- it('handles backslash properly', function()
- command('set iskeyword=a,b,c')
- command('set iskeyword+=d')
- eq('a,b,c,d', eval('&iskeyword'))
-
- command([[set iskeyword+=\\,e]])
- eq([[a,b,c,d,\,e]], eval('&iskeyword'))
-
- command('set iskeyword-=e')
- eq([[a,b,c,d,\]], eval('&iskeyword'))
-
- command([[set iskeyword-=\]])
- eq('a,b,c,d', eval('&iskeyword'))
- end)
-
- it('recognizes a trailing comma with +=', function()
- command('set wildignore=*.png,')
- command('set wildignore+=*.jpg')
- eq('*.png,*.jpg', eval('&wildignore'))
- end)
-end)
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index 1269a2350c..83d794b620 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -110,6 +110,7 @@ describe('vim.lsp.diagnostic', function()
}
]]
eq({code = 42, tags = {"foo", "bar"}, data = "Hello world"}, result[1].user_data.lsp)
+ eq(42, result[1].code)
eq(42, result[2].code)
eq({"foo", "bar"}, result[2].tags)
eq("Hello world", result[2].data)
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index d909888613..c5315d0185 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -94,7 +94,7 @@ local function screen_setup(extra_rows, command, cols, opts)
table.insert(expected, '{3:-- TERMINAL --}' .. ((' '):rep(cols - 14)))
screen:expect(table.concat(expected, '|\n')..'|')
else
- -- This eval also acts as a wait().
+ -- This eval also acts as a poke_eventloop().
if 0 == nvim('eval', "exists('b:terminal_job_id')") then
error("terminal job failed to start")
end
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index c44e59cfd3..d521e3cd25 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -2324,7 +2324,7 @@ describe('builtin popupmenu', function()
it('is closed by :stopinsert from timer #12976', function()
screen:try_resize(32,14)
command([[call setline(1, ['hello', 'hullo', 'heeee', ''])]])
- feed('Gah<C-N>')
+ feed('Gah<c-x><c-n>')
screen:expect([[
hello |
hullo |
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 61f19c3794..a5af898652 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -576,16 +576,16 @@ to the test if they make sense.
print([[
warning: Screen changes were received after the expected state. This indicates
-indeterminism in the test. Try adding screen:expect(...) (or wait()) between
-asynchronous (feed(), nvim_input()) and synchronous API calls.
+indeterminism in the test. Try adding screen:expect(...) (or poke_eventloop())
+between asynchronous (feed(), nvim_input()) and synchronous API calls.
- Use screen:redraw_debug() to investigate; it may find relevant intermediate
states that should be added to the test to make it more robust.
- If the purpose of the test is to assert state after some user input sent
with feed(), adding screen:expect() before the feed() will help to ensure
the input is sent when Nvim is in a predictable state. This is preferable
- to wait(), for being closer to real user interaction.
- - wait() can trigger redraws and consequently generate more indeterminism.
- Try removing wait().
+ to poke_eventloop(), for being closer to real user interaction.
+ - poke_eventloop() can trigger redraws and thus generate more indeterminism.
+ Try removing poke_eventloop().
]])
did_warn = true
end