From 59e96717d21cbee77ea2359fbd5737d42a986fd2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 13:10:44 -0400 Subject: [PATCH 1/7] vim-patch:8.2.3019: location list only has the start position. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Location list only has the start position. Solution: Make it possible to add an end position. (Shane-XB-Qian, closes vim/vim#8393) https://github.com/vim/vim/commit/6864efa59636ccede2af24e3f5f92d78d210d77b N/A patches for version.c: vim-patch:8.2.3002: Vim doesn't abort on a fatal Tcl error Problem: Vim doesn't abort on a fatal Tcl error. Solution: Change emsg() to iemsg(). (Dominique Pellé, closes vim/vim#8383) https://github.com/vim/vim/commit/affd0bc626560631f1df2e0f68db2f15dbda47e1 vim-patch:8.2.3030: Coverity reports a memory leak Problem: Coverity reports a memory leak. Solution: Fix the leak and a few typos. (Dominique Pellé, closes vim/vim#8418) https://github.com/vim/vim/commit/cb54bc65625abad9a0af501acac5c70fba17e2cc Patch v8.2.3022 is mostly N/A but cannot be included here because of new feature check for "has()". vim-patch:8.2.3032: build problems with MSVC, other crypt issues with libsodium Problem: Build problems with MSVC, other crypt issues with libsodium. Solution: Adjust MSVC makefile. Disable swap file only when 'key' is set. Adjust error message used when key is wrong. Fix Coverity issues. (Christian Brabandt, closes vim/vim#8420, closes vim/vim#8411) https://github.com/vim/vim/commit/226b28b96150e59375d2bff44e0aadd382b0c3f1 vim-patch:8.2.3044: Amiga MorphOS and AROS: process ID is not valid Problem: Amiga MorphOS and AROS: process ID is not valid. Solution: Use FindTask to return something which is unique to all processes. (Ola Söder, closes vim/vim#8444) https://github.com/vim/vim/commit/3a62b14077c51c739cdc755356882b40c299f1c0 vim-patch:8.2.3046: Amiga MorphOS: Term mode is set using DOS packets Problem: Amiga MorphOS: Term mode is set using DOS packets. Solution: Use the same way of setting term mdoe on all next gen Amiga-like systems. (Ola Söder, closes vim/vim#8445) https://github.com/vim/vim/commit/b420ac9d20d484ba0ebf3e328069251a63f96996 --- runtime/doc/eval.txt | 3 + src/nvim/quickfix.c | 101 +++++++++++++++++++++-------- src/nvim/testdir/test_quickfix.vim | 37 +++++++++-- src/nvim/testdir/test_tagjump.vim | 13 ++-- 4 files changed, 115 insertions(+), 39 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 83e10d649d..9f63f79535 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4759,7 +4759,10 @@ getqflist([{what}]) *getqflist()* bufname() to get the name module module name lnum line number in the buffer (first line is 1) + end_lnum + end of line number if the item is multiline col column number (first column is 1) + end_col end of column number if the item has range vcol |TRUE|: "col" is visual column |FALSE|: "col" is byte index nr error number diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 7c7b790d5c..d09dfac840 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -54,20 +54,23 @@ struct dir_stack_T { // For each error the next struct is allocated and linked in a list. typedef struct qfline_S qfline_T; struct qfline_S { - qfline_T *qf_next; ///< pointer to next error in the list - qfline_T *qf_prev; ///< pointer to previous error in the list - linenr_T qf_lnum; ///< line number where the error occurred - int qf_fnum; ///< file number for the line - int qf_col; ///< column where the error occurred - int qf_nr; ///< error number - char_u *qf_module; ///< module name for this error - char_u *qf_pattern; ///< search pattern for the error - char_u *qf_text; ///< description of the error - char_u qf_viscol; ///< set to TRUE if qf_col is screen column - char_u qf_cleared; ///< set to TRUE if line has been deleted - char_u qf_type; ///< type of the error (mostly 'E'); 1 for - // :helpgrep - char_u qf_valid; ///< valid error message detected + qfline_T *qf_next; ///< pointer to next error in the list + qfline_T *qf_prev; ///< pointer to previous error in the list + linenr_T qf_lnum; ///< line number where the error occurred + linenr_T qf_end_lnum; ///< line number when the error has range or zero + + int qf_fnum; ///< file number for the line + int qf_col; ///< column where the error occurred + int qf_end_col; ///< column when the error has range or zero + int qf_nr; ///< error number + char_u *qf_module; ///< module name for this error + char_u *qf_pattern; ///< search pattern for the error + char_u *qf_text; ///< description of the error + char_u qf_viscol; ///< set to TRUE if qf_col and qf_end_col is + // screen column + char_u qf_cleared; ///< set to TRUE if line has been deleted + char_u qf_type; ///< type of the error (mostly 'E'); 1 for :helpgrep + char_u qf_valid; ///< valid error message detected }; // There is a stack of error lists. @@ -197,7 +200,9 @@ typedef struct { char_u *errmsg; size_t errmsglen; long lnum; + long end_lnum; int col; + int end_col; bool use_viscol; char_u *pattern; int enr; @@ -282,7 +287,9 @@ static int qf_init_process_nextline(qf_list_T *qfl, 0, fields->errmsg, fields->lnum, + fields->end_lnum, fields->col, + fields->end_col, fields->use_viscol, fields->pattern, fields->enr, @@ -1561,7 +1568,9 @@ static int qf_parse_get_fields(char_u *linebuf, size_t linelen, efm_T *fmt_ptr, fields->errmsg[0] = NUL; } fields->lnum = 0; + fields->end_lnum = 0; fields->col = 0; + fields->end_col = 0; fields->use_viscol = false; fields->enr = -1; fields->type = 0; @@ -1799,7 +1808,9 @@ void check_quickfix_busy(void) /// @param bufnum buffer number or zero /// @param mesg message /// @param lnum line number +/// @param end_lnum line number for end /// @param col column +/// @param end_col column for end /// @param vis_col using visual column /// @param pattern search pattern /// @param nr error number @@ -1808,8 +1819,9 @@ void check_quickfix_busy(void) /// /// @returns QF_OK or QF_FAIL. static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, - char_u *module, int bufnum, char_u *mesg, long lnum, - int col, char_u vis_col, char_u *pattern, int nr, + char_u *module, int bufnum, char_u *mesg, + long lnum, long end_lnum, int col, int end_col, + char_u vis_col, char_u *pattern, int nr, char_u type, char_u valid) { qfline_T *qfp = xmalloc(sizeof(qfline_T)); @@ -1828,7 +1840,9 @@ static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname, } qfp->qf_text = vim_strsave(mesg); qfp->qf_lnum = lnum; + qfp->qf_end_lnum = end_lnum; qfp->qf_col = col; + qfp->qf_end_col = end_col; qfp->qf_viscol = vis_col; if (pattern == NULL || *pattern == NUL) { qfp->qf_pattern = NULL; @@ -1957,7 +1971,9 @@ static int copy_loclist_entries(const qf_list_T *from_qfl, qf_list_T *to_qfl) 0, from_qfp->qf_text, from_qfp->qf_lnum, + from_qfp->qf_end_lnum, from_qfp->qf_col, + from_qfp->qf_end_col, from_qfp->qf_viscol, from_qfp->qf_pattern, from_qfp->qf_nr, @@ -3108,11 +3124,8 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel) } if (qfp->qf_lnum == 0) { IObuff[0] = NUL; - } else if (qfp->qf_col == 0) { - vim_snprintf((char *)IObuff, IOSIZE, "%" PRIdLINENR, qfp->qf_lnum); } else { - vim_snprintf((char *)IObuff, IOSIZE, "%" PRIdLINENR " col %d", - qfp->qf_lnum, qfp->qf_col); + qf_range_text(qfp, IObuff, IOSIZE); } vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE, "%s", (char *)qf_types(qfp->qf_type, qfp->qf_nr)); @@ -3232,6 +3245,32 @@ static void qf_fmt_text(const char_u *restrict text, char_u *restrict buf, buf[i] = NUL; } +// Range information from lnum, col, end_lnum, and end_col. +// Put the result in "buf[bufsize]". +static void qf_range_text(const qfline_T *qfp, char_u *buf, int bufsize) +{ + vim_snprintf((char *)buf, (size_t)bufsize, "%" PRIdLINENR, qfp->qf_lnum); + int len = (int)STRLEN(buf); + + if (qfp->qf_end_lnum > 0 && qfp->qf_lnum != qfp->qf_end_lnum) { + vim_snprintf((char *)buf + len, (size_t)(bufsize - len), + "-%" PRIdLINENR, qfp->qf_end_lnum); + len += (int)STRLEN(buf + len); + } + if (qfp->qf_col > 0) { + vim_snprintf((char *)buf + len, (size_t)(bufsize - len), + " col %d", qfp->qf_col); + len += (int)STRLEN(buf + len); + if (qfp->qf_end_col > 0 && qfp->qf_col != qfp->qf_end_col) { + vim_snprintf((char *)buf + len, (size_t)(bufsize - len), + "-%d", qfp->qf_end_col); + len += (int)STRLEN(buf + len); + } + } + buf[len] = NUL; +} + + /// Display information (list number, list size and the title) about a /// quickfix/location list. static void qf_msg(qf_info_T *qi, int which, char *lead) @@ -4005,16 +4044,9 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum, IObuff[len++] = '|'; } if (qfp->qf_lnum > 0) { - snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), "%" PRId64, - (int64_t)qfp->qf_lnum); + qf_range_text(qfp, IObuff + len, IOSIZE - len); len += (int)STRLEN(IObuff + len); - if (qfp->qf_col > 0) { - snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), " col %d", - qfp->qf_col); - len += (int)STRLEN(IObuff + len); - } - snprintf((char *)IObuff + len, (size_t)(IOSIZE - len), "%s", (char *)qf_types(qfp->qf_type, qfp->qf_nr)); len += (int)STRLEN(IObuff + len); @@ -5263,7 +5295,9 @@ static bool vgr_match_buflines(qf_list_T *qfl, char_u *fname, buf_T *buf, ml_get_buf(buf, regmatch->startpos[0].lnum + lnum, false), regmatch->startpos[0].lnum + lnum, + regmatch->endpos[0].lnum + lnum, regmatch->startpos[0].col + 1, + regmatch->endpos[0].col + 1, false, // vis_col NULL, // search pattern 0, // nr @@ -5765,7 +5799,11 @@ static int get_qfline_items(qfline_T *qfp, list_T *list) if (tv_dict_add_nr(dict, S_LEN("bufnr"), (varnumber_T)bufnum) == FAIL || (tv_dict_add_nr(dict, S_LEN("lnum"), (varnumber_T)qfp->qf_lnum) == FAIL) + || (tv_dict_add_nr(dict, S_LEN("end_lnum"), (varnumber_T)qfp->qf_end_lnum) + == FAIL) || (tv_dict_add_nr(dict, S_LEN("col"), (varnumber_T)qfp->qf_col) == FAIL) + || (tv_dict_add_nr(dict, S_LEN("end_col"), (varnumber_T)qfp->qf_end_col) + == FAIL) || (tv_dict_add_nr(dict, S_LEN("vcol"), (varnumber_T)qfp->qf_viscol) == FAIL) || (tv_dict_add_nr(dict, S_LEN("nr"), (varnumber_T)qfp->qf_nr) == FAIL) @@ -6263,7 +6301,9 @@ static int qf_add_entry_from_dict( char *const module = tv_dict_get_string(d, "module", true); int bufnum = (int)tv_dict_get_number(d, "bufnr"); const long lnum = (long)tv_dict_get_number(d, "lnum"); + const long end_lnum = (long)tv_dict_get_number(d, "end_lnum"); const int col = (int)tv_dict_get_number(d, "col"); + const int end_col = (int)tv_dict_get_number(d, "end_col"); const char_u vcol = (char_u)tv_dict_get_number(d, "vcol"); const int nr = (int)tv_dict_get_number(d, "nr"); const char *const type = tv_dict_get_string(d, "type", false); @@ -6301,7 +6341,9 @@ static int qf_add_entry_from_dict( bufnum, (char_u *)text, lnum, + end_lnum, col, + end_col, vcol, // vis_col (char_u *)pattern, // search pattern nr, @@ -7035,7 +7077,10 @@ static void hgr_search_file( 0, line, lnum, + 0, (int)(p_regmatch->startp[0] - line) + 1, // col + (int)(p_regmatch->endp[0] - line) + + 1, // end_col false, // vis_col NULL, // search pattern 0, // nr diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index c0b9dd7696..3c5ef201f9 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -134,6 +134,21 @@ func XlistTests(cchar) call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) + " Ranged entries + call g:Xsetlist([{'lnum':10,'text':'Line1'}, + \ {'lnum':20,'col':10,'text':'Line2'}, + \ {'lnum':30,'col':15,'end_col':20,'text':'Line3'}, + \ {'lnum':40,'end_lnum':45,'text':'Line4'}, + \ {'lnum':50,'end_lnum':55,'col':15,'text':'Line5'}, + \ {'lnum':60,'end_lnum':65,'col':25,'end_col':35,'text':'Line6'}]) + let l = split(execute('Xlist', ""), "\n") + call assert_equal([' 1:10: Line1', + \ ' 2:20 col 10: Line2', + \ ' 3:30 col 15-20: Line3', + \ ' 4:40-45: Line4', + \ ' 5:50-55 col 15: Line5', + \ ' 6:60-65 col 25-35: Line6'], l) + " Different types of errors call g:Xsetlist([{'lnum':10,'col':5,'type':'W', 'text':'Warning','nr':11}, \ {'lnum':20,'col':10,'type':'e','text':'Error','nr':22}, @@ -599,6 +614,7 @@ func s:test_xhelpgrep(cchar) call assert_true(&buftype == 'help') call assert_true(winnr() == 1) call assert_true(winnr('$') == 2) + call assert_match('|\d\+ col \d\+-\d\+|', getbufline(winbufnr(2), 1)[0]) " This wipes out the buffer, make sure that doesn't cause trouble. Xclose @@ -1437,10 +1453,13 @@ func SetXlistTests(cchar, bnum) call s:setup_commands(a:cchar) call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, - \ {'bufnr': a:bnum, 'lnum': 2}]) + \ {'bufnr': a:bnum, 'lnum': 2, 'end_lnum': 3, 'col': 4, 'end_col': 5}]) let l = g:Xgetlist() call assert_equal(2, len(l)) call assert_equal(2, l[1].lnum) + call assert_equal(3, l[1].end_lnum) + call assert_equal(4, l[1].col) + call assert_equal(5, l[1].end_col) Xnext call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a') @@ -2743,7 +2762,9 @@ func XvimgrepTests(cchar) let l = g:Xgetlist() call assert_equal(2, len(l)) call assert_equal(8, l[0].col) + call assert_equal(11, l[0].end_col) call assert_equal(12, l[1].col) + call assert_equal(15, l[1].end_col) 1Xvimgrep ?Editor? Xtestfile* let l = g:Xgetlist() @@ -4850,7 +4871,7 @@ func Test_add_invalid_entry_with_qf_window() call setqflist(['bb'], 'a') call assert_equal(1, line('$')) call assert_equal(['Xfile1|10| aa'], getline(1, '$')) - call assert_equal([{'lnum': 10, 'bufnr': bufnr('Xfile1'), 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist()) + call assert_equal([{'lnum': 10, 'end_lnum': 0, 'bufnr': bufnr('Xfile1'), 'col': 0, 'end_col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist()) cclose endfunc @@ -5001,15 +5022,21 @@ func Xtest_qftextfunc(cchar) call assert_equal('Tqfexpr', &quickfixtextfunc) call assert_equal('', \ g:Xgetlist({'quickfixtextfunc' : 1}).quickfixtextfunc) - Xexpr ['F1:10:2:green', 'F1:20:4:blue'] + call g:Xsetlist([ + \ { 'filename': 'F1', 'lnum': 10, 'col': 2, + \ 'end_col': 7, 'text': 'green'}, + \ { 'filename': 'F1', 'lnum': 20, 'end_lnum': 25, 'col': 4, + \ 'end_col': 8, 'text': 'blue'}, + \ ]) + Xwindow call assert_equal('F1-L10C2-green', getline(1)) call assert_equal('F1-L20C4-blue', getline(2)) Xclose set quickfixtextfunc&vim Xwindow - call assert_equal('F1|10 col 2| green', getline(1)) - call assert_equal('F1|20 col 4| blue', getline(2)) + call assert_equal('F1|10 col 2-7| green', getline(1)) + call assert_equal('F1|20-25 col 4-8| blue', getline(2)) Xclose set efm& set quickfixtextfunc& diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index 9f02af7d8e..68dcfb6890 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -771,15 +771,16 @@ func Test_ltag() ltag third call assert_equal('Xfoo', bufname('')) call assert_equal(3, line('.')) - call assert_equal([{'lnum': 3, 'bufnr': bufnr('Xfoo'), 'col': 0, - \ 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', - \ 'module': '', 'text': 'third'}], getloclist(0)) + call assert_equal([{'lnum': 3, 'end_lnum': 0, 'bufnr': bufnr('Xfoo'), + \ 'col': 0, 'end_col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, + \ 'nr': 0, 'type': '', 'module': '', 'text': 'third'}], getloclist(0)) ltag second call assert_equal(2, line('.')) - call assert_equal([{'lnum': 0, 'bufnr': bufnr('Xfoo'), 'col': 0, - \ 'pattern': '^\Vint second() {}\$', 'valid': 1, 'vcol': 0, 'nr': 0, - \ 'type': '', 'module': '', 'text': 'second'}], getloclist(0)) + call assert_equal([{'lnum': 0, 'end_lnum': 0, 'bufnr': bufnr('Xfoo'), + \ 'col': 0, 'end_col': 0, 'pattern': '^\Vint second() {}\$', + \ 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'module': '', + \ 'text': 'second'}], getloclist(0)) call delete('Xtags') call delete('Xfoo') From 64ad770fbe387060ece5ebde786921bff65c30e6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 13:48:29 -0400 Subject: [PATCH 2/7] vim-patch:8.2.3025: not enough tests for quickfix end_col and end_lnum Problem: Not enough tests for quickfix end_col and end_lnum. Solution: Add a few more test cases. (Shane-XB-Qian, closes vim/vim#8409) https://github.com/vim/vim/commit/0d5e1ec37fbe75e18acba6f650c59bf91063108c --- src/nvim/testdir/test_quickfix.vim | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 3c5ef201f9..73b7fa69e7 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -4871,7 +4871,42 @@ func Test_add_invalid_entry_with_qf_window() call setqflist(['bb'], 'a') call assert_equal(1, line('$')) call assert_equal(['Xfile1|10| aa'], getline(1, '$')) - call assert_equal([{'lnum': 10, 'end_lnum': 0, 'bufnr': bufnr('Xfile1'), 'col': 0, 'end_col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist()) + call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': 0 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 0 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10 col 666| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 0 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10 col 666| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': -456 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10 col 666-222| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': -123 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) + + call setqflist([{'lnum': 10 , 'end_lnum': 6 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , 'r') + call assert_equal(1 , line('$')) + call assert_equal(['Xfile1|10-6 col 666-222| aa'] , getline(1 , '$')) + call assert_equal([{'lnum': 10 , 'end_lnum': 6 , 'bufnr': bufnr('Xfile1') , 'col': 666 , 'end_col': 222 , 'pattern': '' , 'valid': 1 , 'vcol': 0 , 'nr': -1 , 'type': '' , 'module': '' , 'text': 'aa'}] , getqflist()) cclose endfunc From 8738ce8c41dc8b341202ddcf9f25459c3d6107d9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 14:16:22 -0400 Subject: [PATCH 3/7] vim-patch:8.2.3163: location list window may open a wrong file Problem: Location list window may open a wrong file. Solution: Also update the qf_ptr field. (Wei-Chung Wen, closes vim/vim#8565, closes vim/vim#8566) https://github.com/vim/vim/commit/1557b16dad2b1a3466a93d015575cd7fdb4661c9 --- src/nvim/quickfix.c | 1 + src/nvim/testdir/test_quickfix.vim | 33 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index d09dfac840..0cfb7c192f 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3014,6 +3014,7 @@ static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit, } qfl->qf_index = qf_index; + qfl->qf_ptr = qf_ptr; if (qf_win_pos_update(qi, old_qf_index)) { // No need to print the error message if it's visible in the error // window diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 73b7fa69e7..5cfea483e2 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -5258,4 +5258,37 @@ func Test_qftextfunc_other_loclist() %bw! endfunc +func Test_locationlist_open_in_newtab() + call s:create_test_file('Xqftestfile1') + call s:create_test_file('Xqftestfile2') + call s:create_test_file('Xqftestfile3') + + %bwipe! + + lgetexpr ['Xqftestfile1:5:Line5', + \ 'Xqftestfile2:10:Line10', + \ 'Xqftestfile3:16:Line16'] + + silent! llast + call assert_equal(1, tabpagenr('$')) + call assert_equal('Xqftestfile3', bufname()) + + set switchbuf=newtab + + silent! lfirst + call assert_equal(2, tabpagenr('$')) + call assert_equal('Xqftestfile1', bufname()) + + silent! lnext + call assert_equal(3, tabpagenr('$')) + call assert_equal('Xqftestfile2', bufname()) + + call delete('Xqftestfile1') + call delete('Xqftestfile2') + call delete('Xqftestfile3') + set switchbuf&vim + + %bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab From e4fedf5156995defc547d92cfe155febeed89872 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 14:19:13 -0400 Subject: [PATCH 4/7] vim-patch:8.2.3254: win_gettype() does not recognize a quickfix window Problem: win_gettype() does not recognize a quickfix window. Solution: Add "quickfix" and "loclist". (Yegappan Lakshmanan, closes vim/vim#8676) https://github.com/vim/vim/commit/28d8421bfb3327d7a5e81369977e8fc108b0229e --- runtime/doc/eval.txt | 6 ++++-- src/nvim/eval/funcs.c | 3 +++ src/nvim/testdir/test_quickfix.vim | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9f63f79535..a76298c86c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9323,10 +9323,12 @@ win_gettype([{nr}]) *win_gettype()* Return the type of the window: "autocmd" autocommand window. Temporary window used to execute autocommands. - "popup" popup window |popup| - "preview" preview window |preview-window| "command" command-line window |cmdwin| (empty) normal window + "loclist" |location-list-window| + "popup" popup window |popup| + "preview" preview window |preview-window| + "quickfix" |quickfix-window| "unknown" window {nr} not found When {nr} is omitted return the type of the current window. diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index f4735b3751..21c858373c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -11392,6 +11392,9 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = vim_strsave((char_u *)"popup"); } else if (wp == curwin && cmdwin_type != 0) { rettv->vval.v_string = vim_strsave((char_u *)"command"); + } else if (bt_quickfix(wp->w_buffer)) { + rettv->vval.v_string = vim_strsave((char_u *)(wp->w_llist_ref != NULL ? + "loclist" : "quickfix")); } } diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 5cfea483e2..5090584e41 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -5291,4 +5291,21 @@ func Test_locationlist_open_in_newtab() %bwipe! endfunc +" Test for win_gettype() in quickfix and location list windows +func Test_win_gettype() + copen + call assert_equal("quickfix", win_gettype()) + let wid = win_getid() + wincmd p + call assert_equal("quickfix", win_gettype(wid)) + cclose + lexpr '' + lopen + call assert_equal("loclist", win_gettype()) + let wid = win_getid() + wincmd p + call assert_equal("loclist", win_gettype(wid)) + lclose +endfunc + " vim: shiftwidth=2 sts=2 expandtab From 5cead86975f89bf0e1765afcd10ded64d5b51346 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 16:49:25 -0400 Subject: [PATCH 5/7] fixup! vim-patch:8.2.3019: location list only has the start position. --- test/functional/ex_cmds/quickfix_commands_spec.lua | 10 +++++----- test/functional/plugin/lsp_spec.lua | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua index 3392a90270..06dafa9ab9 100644 --- a/test/functional/ex_cmds/quickfix_commands_spec.lua +++ b/test/functional/ex_cmds/quickfix_commands_spec.lua @@ -37,9 +37,9 @@ for _, c in ipairs({'l', 'c'}) do -- Second line of each entry (i.e. `nr=-1, …`) was obtained from actual -- results. First line (i.e. `{lnum=…`) was obtained from legacy test. local list = { - {lnum=700, col=10, text='Line 700', module='', + {lnum=700, end_lnum=0, col=10, end_col=0, text='Line 700', module='', nr=-1, bufnr=2, valid=1, pattern='', vcol=0, ['type']=''}, - {lnum=800, col=15, text='Line 800', module='', + {lnum=800, end_lnum=0, col=15, end_col=0, text='Line 800', module='', nr=-1, bufnr=3, valid=1, pattern='', vcol=0, ['type']=''}, } eq(list, getlist()) @@ -58,7 +58,7 @@ for _, c in ipairs({'l', 'c'}) do ]]):format(file)) command(('%s %s'):format(addfcmd, file)) list[#list + 1] = { - lnum=900, col=30, text='Line 900', module='', + lnum=900, end_lnum=0, col=30, end_col=0, text='Line 900', module='', nr=-1, bufnr=5, valid=1, pattern='', vcol=0, ['type']='', } eq(list, getlist()) @@ -71,9 +71,9 @@ for _, c in ipairs({'l', 'c'}) do command('enew!') command(('%s %s'):format(getfcmd, file)) list = { - {lnum=222, col=77, text='Line 222', module='', + {lnum=222, end_lnum=0, col=77, end_col=0, text='Line 222', module='', nr=-1, bufnr=2, valid=1, pattern='', vcol=0, ['type']=''}, - {lnum=333, col=88, text='Line 333', module='', + {lnum=333, end_lnum=0, col=88, end_col=0, text='Line 333', module='', nr=-1, bufnr=3, valid=1, pattern='', vcol=0, ['type']=''}, } eq(list, getlist()) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index e5533af73b..b77a285379 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2026,7 +2026,9 @@ describe('LSP', function() local expected = { { bufnr = 2, col = 5, + end_col = 0, lnum = 4, + end_lnum = 0, module = "", nr = 0, pattern = "", @@ -2098,7 +2100,9 @@ describe('LSP', function() local expected = { { bufnr = 2, col = 5, + end_col = 0, lnum = 4, + end_lnum = 0, module = "", nr = 0, pattern = "", From 18b12bcee1b316d9eb62d80a086886d1685525ee Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 17:19:17 -0400 Subject: [PATCH 6/7] vim-patch:8.2.3115: Coverity complains about free_wininfo() use Problem: Coverity complains about free_wininfo() use. Solution: Add a condition that "wip2" is not equal to "wip". (Neovim vim/vim#14996) https://github.com/vim/vim/commit/b5098060f4acae4dac3203130278c948d670a3d5 This fix came from https://github.com/neovim/neovim/pull/14996. This commit adds only a comment to be in sync with Vim. N/A patches for version.c: vim-patch:8.2.3063: crash when switching 'cryptmethod' to xchaha20 with undo file Problem: Crash when switching 'cryptmethod' to xchaha20 with an existing undo file. (Martin Tournoij) Solution: Disable reading undo file when decoding can't be done inplace. (issue vim/vim#8467) https://github.com/vim/vim/commit/65aee0b714e809b9f19862f3decd35055ed4de10 vim-patch:8.2.3101: missing function prototype for vim_round() Problem: Missing function prototype for vim_round(). Solution: Add the prototype. https://github.com/vim/vim/commit/67b17a6fc62156383d24dcbd6e6df34e180d7235 vim-patch:8.2.3119: compiler warning for unused argument Problem: Compiler warning for unused argument. Solution: Add UNUSED. https://github.com/vim/vim/commit/6a9e5c69cf36676e65ae191264872a3e41bde37f vim-patch:8.2.3120: crypt with sodium test fails on MS-Windows Problem: Crypt with sodium test fails on MS-Windows. Solution: Make the tests pass. (closes vim/vim#8428) https://github.com/vim/vim/commit/db8647277082a8a69a189ded8bd1408af993b54e vim-patch:8.2.3131: MS-Windows: ipv6 channel test is very flaky in the GUI Problem: MS-Windows: ipv6 channel test is very flaky in the GUI. Solution: Skip the test. https://github.com/vim/vim/commit/981217c11f92b37f2baa51492cbe12e85d0ea493 vim-patch:8.2.3140: MS-Windows: ipv6 channel test is very flaky also without GUI Problem: MS-Windows: ipv6 channel test is very flaky also without the GUI. Solution: Skip the test also without the GUI. https://github.com/vim/vim/commit/482d2f37a5ce43157ab1e22c26f389770d0c20cf vim-patch:8.2.3157: crypt test may fail on MS-Windows Problem: Crypt test may fail on MS-Windows. Solution: Ignore "[unix]" in the file message. (Christian Brabandt, closes vim/vim#8561) https://github.com/vim/vim/commit/16e26a31161d65baca7885c46c43ab4a48399c92 vim-patch:8.2.3218: when using xchaha20 crypt undo file is not removed Problem: When using xchaha20 crypt undo file is not removed. Solution: Reset 'undofile' and delete the file. (Christian Brabandt, closes vim/vim#8630, closes vim/vim#8467) https://github.com/vim/vim/commit/8a4c812ede5b01a8e71082c1ff4ebfcbf1bd515f vim-patch:8.2.3245: the crypt key may appear in a swap partition Problem: The crypt key may appear in a swap partition. Solution: When using xchaha20 use sodium_mlock(). (Christian Brabandt, closes vim/vim#8657) https://github.com/vim/vim/commit/131530a54d0f72b820b027606231744e3a09b9ef --- src/nvim/window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvim/window.c b/src/nvim/window.c index fb1a4a580b..0856e75758 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4662,6 +4662,7 @@ win_free ( // If there already is an entry with "wi_win" set to NULL it // must be removed, it would never be used. + // Skip "wip" itself, otherwise Coverity complains. for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next) { // `wip2 != wip` to satisfy Coverity. #14884 if (wip2 != wip && wip2->wi_win == NULL) { From 927383f212bfecd224e9071da363c17655a3e415 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 31 Jul 2021 18:28:36 -0400 Subject: [PATCH 7/7] vim-patch:8.2.3136: no test for E187 and "No swap file" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: No test for E187 and "No swap file". Solution: Add a test. (Dominique Pellé, closes vim/vim#8540) https://github.com/vim/vim/commit/fe3418abe0dac65e42e85b5a91c5d0c975bc65bb --- src/nvim/testdir/test_cd.vim | 20 +++++++++++++++++++- src/nvim/testdir/test_swap.vim | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_cd.vim b/src/nvim/testdir/test_cd.vim index 770ed55b8d..02a23bf82f 100644 --- a/src/nvim/testdir/test_cd.vim +++ b/src/nvim/testdir/test_cd.vim @@ -1,4 +1,7 @@ -" Test for :cd +" Test for :cd and chdir() + +source shared.vim +source check.vim func Test_cd_large_path() " This used to crash with a heap write overflow. @@ -65,3 +68,18 @@ func Test_cd_with_cpo_chdir() set cpo& bw! endfunc + +func Test_cd_from_non_existing_dir() + CheckNotMSWindows + + let saveddir = getcwd() + call mkdir('Xdeleted_dir') + cd Xdeleted_dir + call delete(saveddir .. '/Xdeleted_dir', 'd') + + " Expect E187 as the current directory was deleted. + call assert_fails('pwd', 'E187:') + call assert_equal('', getcwd()) + cd - + call assert_equal(saveddir, getcwd()) +endfunc diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index 3c191cd7c7..02bc297de1 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -376,4 +376,8 @@ func Test_swap_symlink() call delete('Xswapdir', 'rf') endfunc +func Test_no_swap_file() + call assert_equal("\nNo swap file", execute('swapname')) +endfunc + " vim: shiftwidth=2 sts=2 expandtab