diff options
27 files changed, 105 insertions, 36 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 009695c13c..8d4f76d3dd 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6516,9 +6516,11 @@ A jump table for the options with a short description can be found at |Q_op|. >= 1 When the shada file is read or written. >= 2 When a file is ":source"'ed. >= 3 UI info, terminal capabilities + >= 4 Shell commands. >= 5 Every searched tags file and include file. >= 8 Files for which a group of autocommands is executed. >= 9 Every executed autocommand. + >= 11 Finding items in a path >= 12 Every executed function. >= 13 When an exception is thrown, caught, finished, or discarded. >= 14 Anything pending in a ":finally" clause. diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 5068f9be76..dc0bca2c60 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Apr 12 +" Last Change: 2020 Apr 29 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -1646,7 +1646,9 @@ au BufNewFile,BufRead */etc/systemd/system/*.d/*.conf setf systemd au BufNewFile,BufRead */.config/systemd/user/*.d/*.conf setf systemd " Systemd temp files au BufNewFile,BufRead */etc/systemd/system/*.d/.#* setf systemd +au BufNewFile,BufRead */etc/systemd/system/.#* setf systemd au BufNewFile,BufRead */.config/systemd/user/*.d/.#* setf systemd +au BufNewFile,BufRead */.config/systemd/user/.#* setf systemd " Synopsys Design Constraints au BufNewFile,BufRead *.sdc setf sdc diff --git a/src/nvim/edit.c b/src/nvim/edit.c index a4c4bf4ce8..ea38221dc7 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -9129,7 +9129,8 @@ static int ins_apply_autocmds(event_T event) // If u_savesub() was called then we are not prepared to start // a new line. Call u_save() with no contents to fix that. - if (tick != buf_get_changedtick(curbuf)) { + // Except when leaving Insert mode. + if (event != EVENT_INSERTLEAVE && tick != buf_get_changedtick(curbuf)) { u_save(curwin->w_cursor.lnum, (linenr_T)(curwin->w_cursor.lnum + 1)); } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index c55a29c67c..ae8557a8bc 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -592,6 +592,8 @@ static void cleanup_function_call(funccall_T *fc) if (!fc_referenced(fc)) { free_funccal(fc, false); } else { + static int made_copy = 0; + // "fc" is still in use. This can happen when returning "a:000", // assigning "l:" to a global variable or defining a closure. // Link "fc" in the list for garbage collection later. @@ -607,6 +609,15 @@ static void cleanup_function_call(funccall_T *fc) TV_LIST_ITER(&fc->l_varlist, li, { tv_copy(TV_LIST_ITEM_TV(li), TV_LIST_ITEM_TV(li)); }); + + if (++made_copy == 10000) { + // We have made a lot of copies. This can happen when + // repetitively calling a function that creates a reference to + // itself somehow. Call the garbage collector soon to avoid using + // too much memory. + made_copy = 0; + want_garbage_collect = true; + } } } diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3694e909d2..fbdd64e43e 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2394,7 +2394,7 @@ int do_in_path(char_u *path, char_u *name, int flags, char_u *rtp_copy = vim_strsave(path); char_u *buf = xmallocz(MAXPATHL); { - if (p_verbose > 1 && name != NULL) { + if (p_verbose > 10 && name != NULL) { verbose_enter(); smsg(_("Searching for \"%s\" in \"%s\""), (char *)name, (char *)path); @@ -2436,7 +2436,7 @@ int do_in_path(char_u *path, char_u *name, int flags, copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); - if (p_verbose > 2) { + if (p_verbose > 10) { verbose_enter(); smsg(_("Searching for \"%s\""), buf); verbose_leave(); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3f7d616b8f..5bf6aa73c6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2476,8 +2476,11 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg) if (*eap->cmd == ';') { if (!eap->skip) { curwin->w_cursor.lnum = eap->line2; - // don't leave the cursor on an illegal line or column - check_cursor(); + // Don't leave the cursor on an illegal line or column, but do + // accept zero as address, so 0;/PATTERN/ works correctly. + if (eap->line2 > 0) { + check_cursor(); + } } } else if (*eap->cmd != ',') { break; diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 532bf68190..e06433892d 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -63,9 +63,12 @@ static void pum_compute_size(void) pum_kind_width = 0; pum_extra_width = 0; for (int i = 0; i < pum_size; i++) { - int w = vim_strsize(pum_array[i].pum_text); - if (pum_base_width < w) { - pum_base_width = w; + int w; + if (pum_array[i].pum_text != NULL) { + w = vim_strsize(pum_array[i].pum_text); + if (pum_base_width < w) { + pum_base_width = w; + } } if (pum_array[i].pum_kind != NULL) { w = vim_strsize(pum_array[i].pum_kind) + 1; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 45c56549c5..8f8bfee60c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5714,6 +5714,7 @@ void grid_puts_line_flush(bool set_cursor) static void start_search_hl(void) { if (p_hls && !no_hlsearch) { + end_search_hl(); // just in case it wasn't called before last_pat_prog(&search_hl.rm); // Set the time limit to 'redrawtime'. search_hl.tm = profile_setlimit(p_rdt); diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index fd49e48c2d..adf7463936 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -98,11 +98,6 @@ func GetAllocId(name) return lnum - top - 1 endfunc -func CanRunVimInTerminal() - " Nvim: always false, we use Lua screen-tests instead. - return 0 -endfunc - func RunTheTest(test) echo 'Executing ' . a:test diff --git a/src/nvim/testdir/screendump.vim b/src/nvim/testdir/screendump.vim index e69de29bb2..8afff1da91 100644 --- a/src/nvim/testdir/screendump.vim +++ b/src/nvim/testdir/screendump.vim @@ -0,0 +1,2 @@ +source shared.vim +source term_util.vim diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim index 3875ffc056..b041fdedb1 100644 --- a/src/nvim/testdir/shared.vim +++ b/src/nvim/testdir/shared.vim @@ -1,10 +1,12 @@ " Functions shared by several tests. " Only load this script once. -if exists('*WaitFor') +if exists('*PythonProg') finish endif +source view_util.vim + " {Nvim} " Filepath captured from output may be truncated, like this: " /home/va...estdir/Xtest-tmpdir/nvimxbXN4i/10 @@ -328,17 +330,6 @@ func RunVimPiped(before, after, arguments, pipecmd) return 1 endfunc -" Get line "lnum" as displayed on the screen. -" Trailing white space is trimmed. -func! Screenline(lnum) - let chars = [] - for c in range(1, winwidth(0)) - call add(chars, nr2char(screenchar(a:lnum, c))) - endfor - let line = join(chars, '') - return matchstr(line, '^.\{-}\ze\s*$') -endfunc - func CanRunGui() return has('gui') && ($DISPLAY != "" || has('gui_running')) endfunc diff --git a/src/nvim/testdir/term_util.vim b/src/nvim/testdir/term_util.vim new file mode 100644 index 0000000000..3a838a3a1f --- /dev/null +++ b/src/nvim/testdir/term_util.vim @@ -0,0 +1,11 @@ +" Functions about terminal shared by several tests + +" Only load this script once. +if exists('*CanRunVimInTerminal') + finish +endif + +func CanRunVimInTerminal() + " Nvim: always false, we use Lua screen-tests instead. + return 0 +endfunc diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim index a924ce0002..076f03fdd8 100644 --- a/src/nvim/testdir/test_bufline.vim +++ b/src/nvim/testdir/test_bufline.vim @@ -1,7 +1,7 @@ " Tests for setbufline(), getbufline(), appendbufline(), deletebufline() source shared.vim -" source screendump.vim +source screendump.vim func Test_setbufline_getbufline() new diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 7f1e1f4456..2c7d64f078 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -801,3 +801,16 @@ func Test_buffers_lastused() bwipeout bufb bwipeout bufc endfunc + +" test that ";" works to find a match at the start of the first line +func Test_zero_line_search() + new + call setline(1, ["1, pattern", "2, ", "3, pattern"]) + call cursor(1,1) + 0;/pattern/d + call assert_equal(["2, ", "3, pattern"], getline(1,'$')) + q! +endfunc + + +" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_debugger.vim b/src/nvim/testdir/test_debugger.vim index 130bcf8910..811717208e 100644 --- a/src/nvim/testdir/test_debugger.vim +++ b/src/nvim/testdir/test_debugger.vim @@ -1,7 +1,7 @@ " Tests for the Vim script debug commands source shared.vim -" source screendump.vim +source screendump.vim " Run a Vim debugger command " If the expected output argument is supplied, then check for it. diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index fed642e34b..42e18ed027 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -1,4 +1,6 @@ " Tests for diff mode +source shared.vim +source screendump.vim func Test_diff_fold_sync() enew! diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 98fa9a3c47..12d5d9790e 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1439,7 +1439,7 @@ func Test_edit_alt() call delete('XAltFile') endfunc -func Test_leave_insert_autocmd() +func Test_edit_InsertLeave() new au InsertLeave * let g:did_au = 1 let g:did_au = 0 @@ -1469,6 +1469,21 @@ func Test_leave_insert_autocmd() iunmap x endfunc +func Test_edit_InsertLeave_undo() + new XtestUndo + set undofile + au InsertLeave * wall + exe "normal ofoo\<Esc>" + call assert_equal(2, line('$')) + normal u + call assert_equal(1, line('$')) + + bwipe! + au! InsertLeave + call delete('XtestUndo') + set undofile& +endfunc + " Test for inserting characters using CTRL-V followed by a number. func Test_edit_special_chars() new diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index c3ddce7914..a9984acdd9 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -437,7 +437,7 @@ let s:filename_checks = { \ 'swiftgyb': ['file.swift.gyb'], \ 'sil': ['file.sil'], \ 'sysctl': ['/etc/sysctl.conf', '/etc/sysctl.d/file.conf'], - \ 'systemd': ['any/systemd/file.automount', 'any/systemd/file.mount', 'any/systemd/file.path', 'any/systemd/file.service', 'any/systemd/file.socket', 'any/systemd/file.swap', 'any/systemd/file.target', 'any/systemd/file.timer', '/etc/systemd/system/some.d/file.conf', '/etc/systemd/system/some.d/.#file', '/home/user/.config/systemd/user/some.d/mine.conf', '/home/user/.config/systemd/user/some.d/.#file'], + \ 'systemd': ['any/systemd/file.automount', 'any/systemd/file.mount', 'any/systemd/file.path', 'any/systemd/file.service', 'any/systemd/file.socket', 'any/systemd/file.swap', 'any/systemd/file.target', 'any/systemd/file.timer', '/etc/systemd/system/some.d/file.conf', '/etc/systemd/system/some.d/.#file', '/etc/systemd/system/.#otherfile', '/home/user/.config/systemd/user/some.d/mine.conf', '/home/user/.config/systemd/user/some.d/.#file', '/home/user/.config/systemd/user/.#otherfile'], \ 'systemverilog': ['file.sv', 'file.svh'], \ 'tags': ['tags'], \ 'tak': ['file.tak'], diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 56ed543d4b..692f6e4780 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -1,6 +1,7 @@ " Test for folding source view_util.vim +source screendump.vim func PrepIndent(arg) return [a:arg] + repeat(["\t".a:arg], 5) diff --git a/src/nvim/testdir/test_highlight.vim b/src/nvim/testdir/test_highlight.vim index a320e8edc8..6aa187b17e 100644 --- a/src/nvim/testdir/test_highlight.vim +++ b/src/nvim/testdir/test_highlight.vim @@ -1,6 +1,7 @@ " Tests for ":highlight" and highlighting. source view_util.vim +source screendump.vim func Test_highlight() " basic test if ":highlight" doesn't crash diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 0a8d52242a..9c9e04be07 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -6,6 +6,9 @@ if !has('mksession') finish endif +source shared.vim +source term_util.vim + func Test_mksession() tabnew let wrap_save = &wrap diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 15b55d35c1..f03c493275 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -271,7 +271,7 @@ func Test_V_arg() call assert_equal(" verbose=0\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq') - " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out) + " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline \\d\\+: sourcing \"[^\"]*runtime[\\/]filetype\.vim\".*\n", out) call assert_match(" verbose=2\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') diff --git a/src/nvim/testdir/test_startup_utf8.vim b/src/nvim/testdir/test_startup_utf8.vim index b24b0eb5cf..1b3d2184a0 100644 --- a/src/nvim/testdir/test_startup_utf8.vim +++ b/src/nvim/testdir/test_startup_utf8.vim @@ -1,7 +1,7 @@ " Tests for startup using utf-8. source shared.vim -" source screendump.vim +source screendump.vim func Test_read_stdin_utf8() let linesin = ['テスト', '€ÀÈÌÒÙ'] diff --git a/src/nvim/testdir/test_suspend.vim b/src/nvim/testdir/test_suspend.vim index ef5a96bd72..4b3bd5eadf 100644 --- a/src/nvim/testdir/test_suspend.vim +++ b/src/nvim/testdir/test_suspend.vim @@ -1,6 +1,7 @@ " Test :suspend source shared.vim +source term_util.vim func CheckSuspended(buf, fileExists) call WaitForAssert({-> assert_match('[$#] $', term_getline(a:buf, '.'))}) @@ -55,7 +56,7 @@ func Test_suspend() call term_wait(buf) " Wait until Vim actually exited and shell shows a prompt call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))}) - call Stop_shell_in_terminal(buf) + call StopShellInTerminal(buf) exe buf . 'bwipe!' call delete('Xfoo') diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index ce9f7adfef..55dff3d476 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -1,6 +1,6 @@ " Tests for tabpage -" source screendump.vim +source screendump.vim function Test_tabpage() bw! diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 40376a877e..cffd80ff4f 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -5,7 +5,7 @@ if !has('timers') endif source shared.vim -source screendump.vim +source term_util.vim source load.vim func MyHandler(timer) diff --git a/src/nvim/testdir/view_util.vim b/src/nvim/testdir/view_util.vim index 520f65c1e7..1def201a05 100644 --- a/src/nvim/testdir/view_util.vim +++ b/src/nvim/testdir/view_util.vim @@ -1,10 +1,21 @@ " Functions about view shared by several tests " Only load this script once. -if exists('*ScreenLines') +if exists('*Screenline') finish endif +" Get line "lnum" as displayed on the screen. +" Trailing white space is trimmed. +func Screenline(lnum) + let chars = [] + for c in range(1, winwidth(0)) + call add(chars, nr2char(screenchar(a:lnum, c))) + endfor + let line = join(chars, '') + return matchstr(line, '^.\{-}\ze\s*$') +endfunc + " ScreenLines(lnum, width) or " ScreenLines([start, end], width) function! ScreenLines(lnum, width) abort |