diff options
-rwxr-xr-x | scripts/legacy2luatest.pl | 41 | ||||
-rw-r--r-- | src/nvim/eval.c | 15 | ||||
-rw-r--r-- | src/nvim/ex_cmds.lua | 85 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 25 | ||||
-rw-r--r-- | src/nvim/ops.c | 8 | ||||
-rw-r--r-- | src/nvim/option.c | 1 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 10 | ||||
-rw-r--r-- | src/nvim/screen.c | 18 | ||||
-rw-r--r-- | src/nvim/search.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test55.in | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test55.ok | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test63.in | 6 | ||||
-rw-r--r-- | src/nvim/version.c | 32 | ||||
-rw-r--r-- | src/nvim/window.c | 27 | ||||
-rw-r--r-- | test/functional/legacy/nested_function_spec.lua | 50 | ||||
-rw-r--r-- | test/functional/legacy/signs_spec.lua | 24 |
16 files changed, 275 insertions, 80 deletions
diff --git a/scripts/legacy2luatest.pl b/scripts/legacy2luatest.pl index 5979afa788..fb14da8157 100755 --- a/scripts/legacy2luatest.pl +++ b/scripts/legacy2luatest.pl @@ -58,11 +58,12 @@ sub read_in_file { unshift @{$command_lines}, @{$input_lines}; unshift @{$command_lines}, "insert([["; - push @{$test_body_lines}, @{$command_lines}; - - @{$command_lines} = (); @{$input_lines} = (); } + + # Output remaining command lines. + push @{$test_body_lines}, @{$command_lines}; + @{$command_lines} = (); } sub format_comment { @@ -173,11 +174,9 @@ sub read_in_file { $state = $states{$state}->($_); } - # If not all input lines have been processed, + # If not all lines have been processed yet, # do it now. - if (@input_lines) { - end_input \@input_lines, \@command_lines, \@test_body_lines; - } + end_input \@input_lines, \@command_lines, \@test_body_lines; close $in_file_handle; @@ -226,13 +225,17 @@ if ($#ARGV != 1) { } my @legacy_suffixes = ('.in', '.ok'); -my ($test_name, $base_path, $suffix) = fileparse($legacy_testfile, @legacy_suffixes); -my $in_file = catfile($base_path, $test_name . '.in'); -my $ok_file = catfile($base_path, $test_name . '.ok'); +my ($base_name, $base_path, $suffix) = fileparse($legacy_testfile, @legacy_suffixes); +my $in_file = catfile($base_path, $base_name . '.in'); +my $ok_file = catfile($base_path, $base_name . '.ok'); + +# Remove leading 'test'. +my $test_name = $base_name; +$test_name =~ s/^test_?//; my $spec_file = do { - if ($test_name =~ /^test([0-9]+)/) { - catfile($out_dir, sprintf('%03d', $1) . '_' . $test_name . '_spec.lua') + if ($test_name =~ /^([0-9]+)/) { + catfile($out_dir, sprintf('%03d', $1) . '_spec.lua') } else { catfile($out_dir, $test_name . '_spec.lua') } @@ -250,7 +253,13 @@ if (! -d $out_dir) { if (-f $spec_file) { say "Output file $spec_file already exists."; - exit 4; + print "Overwrite (Y/n)? "; + my $input = <STDIN>; + chomp($input); + unless ($input =~ /^y|Y/) { + say "Aborting."; + exit 4; + } } # Read .in and .ok files. @@ -267,8 +276,8 @@ print $spec_file_handle <<"EOS"; @{[join "\n", @{$description_lines}]} local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect describe('$test_name', function() setup(clear) @@ -280,3 +289,5 @@ end) EOS close $spec_file_handle; + +say "Written to $spec_file." diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 116944b28d..744fb13447 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2247,7 +2247,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch int ll_n1 = lp->ll_n1; // Check whether any of the list items is locked - for (listitem_T *ri = rettv->vval.v_list->lv_first; ri != NULL; ) { + for (listitem_T *ri = rettv->vval.v_list->lv_first; ri != NULL && ll_li != NULL; ) { if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name)) { return; } @@ -17580,15 +17580,14 @@ void ex_function(exarg_T *eap) /* Check for defining a function inside this function. */ if (checkforcmd(&p, "function", 2)) { - if (*p == '!') + if (*p == '!') { p = skipwhite(p + 1); + } p += eval_fname_script(p); - if (ASCII_ISALPHA(*p)) { - free(trans_function_name(&p, TRUE, 0, NULL)); - if (*skipwhite(p) == '(') { - ++nesting; - indent += 2; - } + free(trans_function_name(&p, TRUE, 0, NULL)); + if (*skipwhite(p) == '(') { + nesting++; + indent += 2; } } diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index c9dd974d11..aade4d736d 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1241,6 +1241,21 @@ return { func='ex_unmap', }, { + command='lua', + flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN), + func='ex_script_ni', + }, + { + command='luado', + flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN), + func='ex_ni', + }, + { + command='luafile', + flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN), + func='ex_ni', + }, + { command='lvimgrep', flags=bit.bor(RANGE, NOTADR, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE), func='ex_vimgrep', @@ -1341,6 +1356,16 @@ return { func='ex_mode', }, { + command='mzscheme', + flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN, SBOXOK), + func='ex_script_ni', + }, + { + command='mzfile', + flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN), + func='ex_ni', + }, + { command='next', flags=bit.bor(RANGE, NOTADR, BANG, FILES, EDITCMD, ARGOPT, TRLBAR), func='ex_next', @@ -1511,6 +1536,16 @@ return { func='ex_pclose', }, { + command='perl', + flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, SBOXOK, CMDWIN), + func='ex_script_ni', + }, + { + command='perldo', + flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN), + func='ex_ni', + }, + { command='pedit', flags=bit.bor(BANG, FILE1, EDITCMD, ARGOPT, TRLBAR), func='ex_pedit', @@ -1636,6 +1671,26 @@ return { func='ex_pyfile', }, { + command='py3', + flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN), + func='ex_script_ni', + }, + { + command='py3do', + flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN), + func='ex_ni', + }, + { + command='python3', + flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN), + func='ex_script_ni', + }, + { + command='py3file', + flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN), + func='ex_ni', + }, + { command='quit', flags=bit.bor(BANG, TRLBAR, CMDWIN), func='ex_quit', @@ -1726,6 +1781,21 @@ return { func='ex_rundo', }, { + command='ruby', + flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN), + func='ex_script_ni', + }, + { + command='rubydo', + flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN), + func='ex_ni', + }, + { + command='rubyfile', + flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN), + func='ex_ni', + }, + { command='rviminfo', flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN), func='ex_viminfo', @@ -2151,6 +2221,21 @@ return { func='ex_tabs', }, { + command='tcl', + flags=bit.bor(RANGE,EXTRA,NEEDARG,CMDWIN), + func='ex_script_ni', + }, + { + command='tcldo', + flags=bit.bor(RANGE,DFLALL,EXTRA,NEEDARG,CMDWIN), + func='ex_ni', + }, + { + command='tclfile', + flags=bit.bor(RANGE,FILE1,NEEDARG,CMDWIN), + func='ex_ni', + }, + { command='tearoff', flags=bit.bor(NEEDARG, EXTRA, TRLBAR, NOTRLCOM, CMDWIN), func='ex_tearoff', diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 359c4b31d1..ca79270fcc 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -138,7 +138,6 @@ struct dbg_stuff { # include "ex_docmd.c.generated.h" #endif -# define HAVE_EX_SCRIPT_NI # define ex_gui ex_nogui # define ex_tearoff ex_ni # define ex_popup ex_ni @@ -1494,9 +1493,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, ni = (!IS_USER_CMDIDX(ea.cmdidx) && (cmdnames[ea.cmdidx].cmd_func == ex_ni -#ifdef HAVE_EX_SCRIPT_NI || cmdnames[ea.cmdidx].cmd_func == ex_script_ni -#endif )); @@ -1832,19 +1829,26 @@ static char_u * do_one_cmd(char_u **cmdlinep, case CMD_leftabove: case CMD_let: case CMD_lockmarks: + case CMD_lua: case CMD_match: + case CMD_mzscheme: case CMD_noautocmd: case CMD_noswapfile: + case CMD_perl: case CMD_psearch: case CMD_python: + case CMD_py3: + case CMD_python3: case CMD_return: case CMD_rightbelow: + case CMD_ruby: case CMD_silent: case CMD_smagic: case CMD_snomagic: case CMD_substitute: case CMD_syntax: case CMD_tab: + case CMD_tcl: case CMD_throw: case CMD_tilde: case CMD_topleft: @@ -1854,7 +1858,8 @@ static char_u * do_one_cmd(char_u **cmdlinep, case CMD_wincmd: break; - default: goto doend; + default: + goto doend; } } @@ -3291,9 +3296,7 @@ static void get_flags(exarg_T *eap) } } -/* - * Function called for command which is Not Implemented. NI! - */ +/// Stub function for command which is Not Implemented. NI! void ex_ni(exarg_T *eap) { if (!eap->skip) @@ -3301,11 +3304,8 @@ void ex_ni(exarg_T *eap) "E319: Sorry, the command is not available in this version"); } -#ifdef HAVE_EX_SCRIPT_NI -/* - * Function called for script command which is Not Implemented. NI! - * Skips over ":perl <<EOF" constructs. - */ +/// Stub function for script command which is Not Implemented. NI! +/// Skips over ":perl <<EOF" constructs. static void ex_script_ni(exarg_T *eap) { if (!eap->skip) @@ -3313,7 +3313,6 @@ static void ex_script_ni(exarg_T *eap) else free(script_get(eap, eap->arg)); } -#endif /* * Check range in Ex command for validity. diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 931b877a95..9b33b6732c 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2979,9 +2979,11 @@ do_put ( } if (VIsual_active) lnum++; - } while ( - VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum - ); + } while (VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum); + + if (VIsual_active) { /* reset lnum to the last visual line */ + lnum--; + } curbuf->b_op_end = curwin->w_cursor; /* For "CTRL-O p" in Insert mode, put cursor after last char */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 1bab0da79a..1c07bef3e3 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3645,6 +3645,7 @@ set_string_option_direct ( idx = findoption(name); if (idx < 0) { /* not found (should not happen) */ EMSG2(_(e_intern2), "set_string_option_direct()"); + EMSG2(_("For option %s"), name); return; } } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 2bf73ce72b..fc3e73c396 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -6011,7 +6011,7 @@ nextchar: /* * Try match of "prog" with at regline["col"]. - * Returns 0 for failure, number of lines contained in the match otherwise. + * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col) { @@ -6116,7 +6116,7 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col) * Match a regexp against a string ("line" points to the string) or multiple * lines ("line" is NULL, use reg_getline()). * - * Returns 0 for failure, number of lines contained in the match otherwise. + * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static long nfa_regexec_both ( @@ -6346,7 +6346,7 @@ static void nfa_regfree(regprog_T *prog) * Uses curbuf for line count and 'iskeyword'. * If "line_lbr" is true, consider a "\n" in "line" to be a line break. * - * Return TRUE if there is a match, FALSE if not. + * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static int nfa_regexec_nl ( @@ -6365,7 +6365,7 @@ nfa_regexec_nl ( ireg_ic = rmp->rm_ic; ireg_icombine = FALSE; ireg_maxcol = 0; - return nfa_regexec_both(line, col) != 0; + return nfa_regexec_both(line, col); } /// Matches a regexp against multiple lines. @@ -6378,7 +6378,7 @@ nfa_regexec_nl ( /// @param col Column to start looking for match /// @param tm Timeout limit or NULL /// -/// @return Zero if there is no match and number of lines contained in the match +/// @return <= 0 if there is no match and number of lines contained in the match /// otherwise. /// /// @note The body is the same as bt_regexec() except for nfa_regexec_both() diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 0148979335..855c09619e 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2962,8 +2962,13 @@ win_line ( if (shl->startcol != MAXCOL && v >= (long)shl->startcol && v < (long)shl->endcol) { + int tmp_col = v + MB_PTR2LEN(ptr); + + if (shl->endcol < tmp_col) { + shl->endcol = tmp_col; + } shl->attr_cur = shl->attr; - } else if (v >= (long)shl->endcol && shl->lnum == lnum) { + } else if (v == (long)shl->endcol) { shl->attr_cur = 0; next_search_hl(wp, shl, lnum, (colnr_T)v, cur); @@ -5733,7 +5738,18 @@ next_search_hl ( shl->lnum = lnum; if (shl->rm.regprog != NULL) { + /* Remember whether shl->rm is using a copy of the regprog in + * cur->match. */ + bool regprog_is_copy = (shl != &search_hl + && cur != NULL + && shl == &cur->hl + && cur->match.regprog == cur->hl.rm.regprog); + nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol, &(shl->tm)); + /* Copy the regprog, in case it got freed and recompiled. */ + if (regprog_is_copy) { + cur->match.regprog = cur->hl.rm.regprog; + } if (called_emsg || got_int) { // Error while handling regexp: stop using this regexp. if (shl == &search_hl) { diff --git a/src/nvim/search.c b/src/nvim/search.c index ef98944a06..5158e6cd86 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3294,10 +3294,11 @@ again: if (VIsual_active) { /* If the end is before the start there is no text between tags, select * the char under the cursor. */ - if (lt(end_pos, start_pos)) + if (lt(end_pos, start_pos)) { curwin->w_cursor = start_pos; - else if (*p_sel == 'e') - ++curwin->w_cursor.col; + } else if (*p_sel == 'e') { + inc_cursor(); + } VIsual = start_pos; VIsual_mode = 'v'; redraw_curbuf_later(INVERTED); /* update the inversion */ diff --git a/src/nvim/testdir/test55.in b/src/nvim/testdir/test55.in index 140cb7c0e5..c4e82d429c 100644 --- a/src/nvim/testdir/test55.in +++ b/src/nvim/testdir/test55.in @@ -401,6 +401,11 @@ let l = [0, 1, 2, 3] : $put =v:exception[:15] . v:exception[-1:-1] :endtry :$put =string(d) +:" +:" test for range assign +:let l = [0] +:let l[:] = [1, 2] +:$put =string(l) :endfun :" :call Test(1, 2, [3, 4], {5: 6}) " This may take a while diff --git a/src/nvim/testdir/test55.ok b/src/nvim/testdir/test55.ok index e8560de401..ba029b2898 100644 --- a/src/nvim/testdir/test55.ok +++ b/src/nvim/testdir/test55.ok @@ -129,6 +129,7 @@ caught a:000[3] {'a': {'b': 'B'}} Vim(call):E737: a {'a': {'b': 'B'}} +[1, 2] Vim(foldopen):E490: diff --git a/src/nvim/testdir/test63.in b/src/nvim/testdir/test63.in index db347a0a87..7fbe0ac434 100644 --- a/src/nvim/testdir/test63.in +++ b/src/nvim/testdir/test63.in @@ -7,9 +7,9 @@ STARTTEST :" --- Check that "matcharg()" returns the correct group and pattern if a match :" --- is defined. :let @r = "*** Test 1: " -:highlight MyGroup1 ctermbg=red guibg=red -:highlight MyGroup2 ctermbg=green guibg=green -:highlight MyGroup3 ctermbg=blue guibg=blue +:highlight MyGroup1 term=bold ctermbg=red guibg=red +:highlight MyGroup2 term=italic ctermbg=green guibg=green +:highlight MyGroup3 term=underline ctermbg=blue guibg=blue :match MyGroup1 /TODO/ :2match MyGroup2 /FIXME/ :3match MyGroup3 /XXX/ diff --git a/src/nvim/version.c b/src/nvim/version.c index fe6f4b1635..c1fe19bb9c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -178,7 +178,7 @@ static char *(features[]) = { }; static int included_patches[] = { - //560, + //560 NA //559, //558 NA //557 NA @@ -189,35 +189,35 @@ static int included_patches[] = { 552, //551, //550, - //549, + 549, //548 NA - //547, + 547, //546, - //545, + 545, //544 NA 543, //542, - //541, + 541, //540 NA //539, - //538, + 538, //537, - //536, + 536, //535, //534 NA - //533, + 533, //532, //531, //530, //529, - //528, - //527, + 528, + 527, //526, //525, //524, //523 NA //522, - //521, + 521, 520, //519, 518, @@ -229,7 +229,7 @@ static int included_patches[] = { //512 NA //511 NA //510 NA - //509, + //509 NA 508, //507 NA //506 NA @@ -251,7 +251,7 @@ static int included_patches[] = { //490, 489, 488, - //487, + 487, 486, 485, //484 NA @@ -294,7 +294,7 @@ static int included_patches[] = { //446, //445, 444, - //443, + //443 NA 442, 441, 440, @@ -335,7 +335,7 @@ static int included_patches[] = { 405, //404 NA //403 NA - //402, + //402 NA //401 NA //400 NA //399 NA @@ -526,7 +526,7 @@ static int included_patches[] = { //214 NA 213, //212 NA - //211, + 211, 210, 209, //208 NA diff --git a/src/nvim/window.c b/src/nvim/window.c index 1a102cf069..ed4a8d8e7a 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3543,27 +3543,28 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri } -/* - * Jump to the first open window that contains buffer "buf", if one exists. - * Returns a pointer to the window found, otherwise NULL. - */ +/// Jump to the first open window that contains buffer "buf", if one exists. +/// Returns a pointer to the window found, otherwise NULL. win_T *buf_jump_open_win(buf_T *buf) { - FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - if (wp->w_buffer == buf) { - win_enter(wp, false); - return wp; + if (curwin->w_buffer == buf) { + win_enter(curwin, false); + return curwin; + } else { + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (wp->w_buffer == buf) { + win_enter(wp, false); + return wp; + } } } return NULL; } -/* - * Jump to the first open window in any tab page that contains buffer "buf", - * if one exists. - * Returns a pointer to the window found, otherwise NULL. - */ +/// Jump to the first open window in any tab page that contains buffer "buf", +/// if one exists. +/// @return the found window, or NULL. win_T *buf_jump_open_tab(buf_T *buf) { diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua new file mode 100644 index 0000000000..87371c8294 --- /dev/null +++ b/test/functional/legacy/nested_function_spec.lua @@ -0,0 +1,50 @@ +-- Tests for nested function. + +local helpers = require('test.functional.helpers') +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local execute, expect, source = helpers.execute, helpers.expect, helpers.source + +describe('test_nested_function', function() + setup(clear) + + it('is working', function() + insert([[ + result:]]) + + source([[ + :fu! NestedFunc() + : fu! Func1() + : $put ='Func1' + : endfunction + : call Func1() + : fu! s:func2() + : $put ='s:func2' + : endfunction + : call s:func2() + : fu! s:_func3() + : $put ='s:_func3' + : endfunction + : call s:_func3() + : let fn = 'Func4' + : fu! {fn}() + : $put ='Func4' + : endfunction + : call {fn}() + : let fn = 'func5' + : fu! s:{fn}() + : $put ='s:func5' + : endfunction + : call s:{fn}() + :endfunction]]) + execute('call NestedFunc()') + + -- Assert buffer contents. + expect([[ + result: + Func1 + s:func2 + s:_func3 + Func4 + s:func5]]) + end) +end) diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua new file mode 100644 index 0000000000..89b2bf3b73 --- /dev/null +++ b/test/functional/legacy/signs_spec.lua @@ -0,0 +1,24 @@ +-- Tests for signs + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('signs', function() + setup(clear) + + it('is working', function() + execute('sign define JumpSign text=x') + execute([[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]]) + -- Split the window to the bottom to verify :sign-jump will stay in the current + -- window if the buffer is displayed there. + execute('bot split') + execute([[exe 'sign jump 42 buffer=' . bufnr('')]]) + execute([[call append(line('$'), winnr())]]) + + -- Assert buffer contents. + expect([[ + + 2]]) + end) +end) |