diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-03 11:03:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 11:03:49 +0200 |
commit | 6891d8aeca9abc24314ad92cb0c669afa13a8769 (patch) | |
tree | 27565ee941cd97515399964f5e22018817a9d022 | |
parent | 9d58a58980c666a3abf515a1dd6b813b13d2d5ae (diff) | |
parent | 96a8b0ab787c7d7148eb4c9881fdb5e022996081 (diff) | |
download | rneovim-6891d8aeca9abc24314ad92cb0c669afa13a8769.tar.gz rneovim-6891d8aeca9abc24314ad92cb0c669afa13a8769.tar.bz2 rneovim-6891d8aeca9abc24314ad92cb0c669afa13a8769.zip |
Merge #9970 from janlazo/vim-8.1.0794
vim-patch:8.0.1708,8.1.{369,794,1242}
-rw-r--r-- | runtime/doc/repeat.txt | 18 | ||||
-rw-r--r-- | runtime/indent/vim.vim | 18 | ||||
-rw-r--r-- | src/nvim/eval.c | 49 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 24 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_eval_stuff.vim | 28 | ||||
-rw-r--r-- | src/nvim/testdir/test_tabpage.vim | 32 | ||||
-rw-r--r-- | src/nvim/window.c | 3 |
8 files changed, 134 insertions, 42 deletions
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 23ae3458ea..0a552a1309 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -432,6 +432,16 @@ flag when defining the function, it is not relevant when executing it. > . :endfunction :set cpo-=C +< + *line-continuation-comment* +To add a comment in between the lines start with '\" '. Notice the space +after the double quote. Example: > + let array = [ + "\ first entry comment + \ 'first', + "\ second entry comment + \ 'second', + \ ] Rationale: Most programs work with a trailing backslash to indicate line @@ -440,6 +450,14 @@ Rationale: :map xx asdf\ < Therefore the unusual leading backslash is used. + Starting a comment in a continuation line results in all following + continuation lines to be part of the comment. Since it was like this + for a long time, when making it possible to add a comment halfway a + sequence of continuation lines, it was not possible to use \", since + that was a valid continuation line. Using '"\ ' comes closest, even + though it may look a bit weird. Requiring the space after the + backslash is to make it very unlikely this is a normal comment line. + ============================================================================== 5. Using Vim packages *packages* diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 8ebfa12caf..cd735c3a3c 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -10,7 +10,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetVimIndent() -setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\ +setlocal indentkeys+==end,=else,=cat,=fina,=END,0\\,0=\"\\\ let b:undo_indent = "setl indentkeys< indentexpr<" @@ -31,15 +31,17 @@ function GetVimIndent() endtry endfunc +let s:lineContPat = '^\s*\(\\\|"\\ \)' + function GetVimIndentIntern() " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) - " If the current line doesn't start with '\' and below a line that starts - " with '\', use the indent of the line above it. + " If the current line doesn't start with '\' or '"\ ' and below a line that + " starts with '\' or '"\ ', use the indent of the line above it. let cur_text = getline(v:lnum) - if cur_text !~ '^\s*\\' - while lnum > 0 && getline(lnum) =~ '^\s*\\' + if cur_text !~ s:lineContPat + while lnum > 0 && getline(lnum) =~ s:lineContPat let lnum = lnum - 1 endwhile endif @@ -51,10 +53,10 @@ function GetVimIndentIntern() let prev_text = getline(lnum) " Add a 'shiftwidth' after :if, :while, :try, :catch, :finally, :function - " and :else. Add it three times for a line that starts with '\' after - " a line that doesn't (or g:vim_indent_cont if it exists). + " and :else. Add it three times for a line that starts with '\' or '"\ ' + " after a line that doesn't (or g:vim_indent_cont if it exists). let ind = indent(lnum) - if cur_text =~ '^\s*\\' && v:lnum > 1 && prev_text !~ '^\s*\\' + if cur_text =~ s:lineContPat && v:lnum > 1 && prev_text !~ s:lineContPat if exists("g:vim_indent_cont") let ind = ind + g:vim_indent_cont else diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b7ae0d4dc1..d5131e976a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12880,33 +12880,36 @@ static void f_mkdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) char buf[NUMBUFLEN]; const char *const dir = tv_get_string_buf(&argvars[0], buf); if (*dir == NUL) { - rettv->vval.v_number = FAIL; - } else { - if (*path_tail((char_u *)dir) == NUL) { - // Remove trailing slashes. - *path_tail_with_sep((char_u *)dir) = NUL; - } + return; + } - if (argvars[1].v_type != VAR_UNKNOWN) { - if (argvars[2].v_type != VAR_UNKNOWN) { - prot = tv_get_number_chk(&argvars[2], NULL); - } - if (prot != -1 && strcmp(tv_get_string(&argvars[1]), "p") == 0) { - char *failed_dir; - int ret = os_mkdir_recurse(dir, prot, &failed_dir); - if (ret != 0) { - EMSG3(_(e_mkdir), failed_dir, os_strerror(ret)); - xfree(failed_dir); - rettv->vval.v_number = FAIL; - return; - } else { - rettv->vval.v_number = OK; - return; - } + if (*path_tail((char_u *)dir) == NUL) { + // Remove trailing slashes. + *path_tail_with_sep((char_u *)dir) = NUL; + } + + if (argvars[1].v_type != VAR_UNKNOWN) { + if (argvars[2].v_type != VAR_UNKNOWN) { + prot = tv_get_number_chk(&argvars[2], NULL); + if (prot == -1) { + return; + } + } + if (strcmp(tv_get_string(&argvars[1]), "p") == 0) { + char *failed_dir; + int ret = os_mkdir_recurse(dir, prot, &failed_dir); + if (ret != 0) { + EMSG3(_(e_mkdir), failed_dir, os_strerror(ret)); + xfree(failed_dir); + rettv->vval.v_number = FAIL; + return; + } else { + rettv->vval.v_number = OK; + return; } } - rettv->vval.v_number = prot == -1 ? FAIL : vim_mkdir_emsg(dir, prot); } + rettv->vval.v_number = vim_mkdir_emsg(dir, prot); } /// "mode()" function diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 15b735dc9e..53a5018fe0 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3403,13 +3403,18 @@ char_u *getsourceline(int c, void *cookie, int indent) // Get the next line and concatenate it when it starts with a // backslash. We always need to read the next line, keep it in // sp->nextline. + // Also check for a comment in between continuation lines: "\ . sp->nextline = get_one_sourceline(sp); - if (sp->nextline != NULL && *(p = skipwhite(sp->nextline)) == '\\') { + if (sp->nextline != NULL + && (*(p = skipwhite(sp->nextline)) == '\\' + || (p[0] == '"' && p[1] == '\\' && p[2] == ' '))) { garray_T ga; ga_init(&ga, (int)sizeof(char_u), 400); ga_concat(&ga, line); - ga_concat(&ga, p + 1); + if (*p == '\\') { + ga_concat(&ga, p + 1); + } for (;; ) { xfree(sp->nextline); sp->nextline = get_one_sourceline(sp); @@ -3417,15 +3422,16 @@ char_u *getsourceline(int c, void *cookie, int indent) break; } p = skipwhite(sp->nextline); - if (*p != '\\') { + if (*p == '\\') { + // Adjust the growsize to the current length to speed up + // concatenating many lines. + if (ga.ga_len > 400) { + ga_set_growsize(&ga, (ga.ga_len > 8000) ? 8000 : ga.ga_len); + } + ga_concat(&ga, p + 1); + } else if (p[0] != '"' || p[1] != '\\' || p[2] != ' ') { break; } - // Adjust the growsize to the current length to speed up - // concatenating many lines. - if (ga.ga_len > 400) { - ga_set_growsize(&ga, (ga.ga_len > 8000) ? 8000 : ga.ga_len); - } - ga_concat(&ga, p + 1); } ga_append(&ga, NUL); xfree(line); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a028814f3d..19bf77a2dc 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4505,8 +4505,8 @@ static int get_tabpage_arg(exarg_T *eap) tab_number = 0; } else { tab_number = eap->line2; - if (!unaccept_arg0 && **eap->cmdlinep == '-') { - --tab_number; + if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-') { + tab_number--; if (tab_number < unaccept_arg0) { eap->errmsg = e_invarg; } diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 111c85bb95..1850fb0cf1 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -21,3 +21,31 @@ func Test_E963() call assert_fails("let v:oldfiles=''", 'E963:') call assert_equal(v_o, v:oldfiles) endfunc + +func Test_mkdir_p() + call mkdir('Xmkdir/nested', 'p') + call assert_true(isdirectory('Xmkdir/nested')) + try + " Trying to make existing directories doesn't error + call mkdir('Xmkdir', 'p') + call mkdir('Xmkdir/nested', 'p') + catch /E739:/ + call assert_report('mkdir(..., "p") failed for an existing directory') + endtry + " 'p' doesn't suppress real errors + call writefile([], 'Xfile') + call assert_fails('call mkdir("Xfile", "p")', 'E739') + call delete('Xfile') + call delete('Xmkdir', 'rf') +endfunc + +func Test_line_continuation() + let array = [5, + "\ ignore this + \ 6, + "\ more to ignore + "\ more moreto ignore + \ ] + "\ and some more + call assert_equal([5, 6], array) +endfunc diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index add9b3d7cf..3c26717b96 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -1,5 +1,6 @@ " Tests for tabpage +" source screendump.vim function Test_tabpage() bw! @@ -105,6 +106,14 @@ function Test_tabpage() call assert_equal(4, tabpagenr()) 7tabmove 5 call assert_equal(5, tabpagenr()) + -tabmove + call assert_equal(4, tabpagenr()) + +tabmove + call assert_equal(5, tabpagenr()) + -2tabmove + call assert_equal(3, tabpagenr()) + +3tabmove + call assert_equal(6, tabpagenr()) " The following are a no-op norm! 2gt @@ -547,4 +556,27 @@ func Test_tabs() bw! endfunc +func Test_tabpage_cmdheight() + if !CanRunVimInTerminal() + throw 'Skipped: only works with terminal' + endif + call writefile([ + \ 'set laststatus=2', + \ 'set cmdheight=2', + \ 'tabnew', + \ 'set cmdheight=3', + \ 'tabnext', + \ 'redraw!', + \ 'echo "hello\nthere"', + \ 'tabnext', + \ 'redraw', + \ ], 'XTest_tabpage_cmdheight') + " Check that cursor line is concealed + let buf = RunVimInTerminal('-S XTest_tabpage_cmdheight', {'statusoff': 3}) + call VerifyScreenDump(buf, 'Test_tabpage_cmdheight', {}) + + call StopVimInTerminal(buf) + call delete('XTest_conceal') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/window.c b/src/nvim/window.c index d9898533da..c6270d6c76 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3793,6 +3793,9 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au * the frames for that. When the Vim window was resized need to update * frame sizes too. Use the stored value of p_ch, so that it can be * different for each tab page. */ + if (p_ch != curtab->tp_ch_used) { + clear_cmdline = true; + } p_ch = curtab->tp_ch_used; if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow )) |