]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1616: quickfix text field is truncated v9.0.1616
authorShane Harper <shane@shaneharper.net>
Wed, 7 Jun 2023 18:09:57 +0000 (19:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Jun 2023 18:09:57 +0000 (19:09 +0100)
Problem:    Quickfix text field is truncated.
Solution:   Fix output of text field after pattern field in quickfix buffer.
            (Shane Harper, closes #12498)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 553ad457880a5d2c5de4a5bb07800b44090bf0cc..4501d11f157be7e123eb09e005b25e89b2e6e7a7 100644 (file)
@@ -3340,6 +3340,7 @@ qf_jump_print_msg(
     // Add the message, skipping leading whitespace and newlines.
     ga_concat(gap, IObuff);
     qf_fmt_text(gap, skipwhite(qf_ptr->qf_text));
+    ga_append(gap, NUL);
 
     // Output the message.  Overwrite to avoid scrolling when the 'O'
     // flag is present in 'shortmess'; But when not jumping, print the
@@ -3660,9 +3661,7 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
     if (qfp->qf_lnum != 0)
        msg_puts_attr(":", qfSepAttr);
     gap = qfga_get();
-    if (qfp->qf_lnum == 0)
-       ga_append(gap, NUL);
-    else
+    if (qfp->qf_lnum != 0)
        qf_range_text(gap, qfp);
     ga_concat(gap, qf_types(qfp->qf_type, qfp->qf_nr));
     ga_append(gap, NUL);
@@ -3672,6 +3671,7 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
     {
        gap = qfga_get();
        qf_fmt_text(gap, qfp->qf_pattern);
+       ga_append(gap, NUL);
        msg_puts((char *)gap->ga_data);
        msg_puts_attr(":", qfSepAttr);
     }
@@ -3682,7 +3682,8 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
     // with ^^^^.
     gap = qfga_get();
     qf_fmt_text(gap, (fname != NULL || qfp->qf_lnum != 0)
-           ? skipwhite(qfp->qf_text) : qfp->qf_text);
+                                    ? skipwhite(qfp->qf_text) : qfp->qf_text);
+    ga_append(gap, NUL);
     msg_prt_line((char_u *)gap->ga_data, FALSE);
     out_flush();               // show one line at a time
 }
@@ -3774,7 +3775,6 @@ qf_list(exarg_T *eap)
 qf_fmt_text(garray_T *gap, char_u *text)
 {
     char_u     *p = text;
-
     while (*p != NUL)
     {
        if (*p == '\n')
@@ -3787,8 +3787,6 @@ qf_fmt_text(garray_T *gap, char_u *text)
        else
            ga_append(gap, *p++);
     }
-
-    ga_append(gap, NUL);
 }
 
 /*
@@ -3807,8 +3805,8 @@ qf_range_text(garray_T *gap, qfline_T *qfp)
 
     if (qfp->qf_end_lnum > 0 && qfp->qf_lnum != qfp->qf_end_lnum)
     {
-       vim_snprintf((char *)buf + len, bufsize - len,
-               "-%ld", qfp->qf_end_lnum);
+       vim_snprintf((char *)buf + len, bufsize - len, "-%ld",
+                                                            qfp->qf_end_lnum);
        len += (int)STRLEN(buf + len);
     }
     if (qfp->qf_col > 0)
@@ -3817,12 +3815,11 @@ qf_range_text(garray_T *gap, qfline_T *qfp)
        len += (int)STRLEN(buf + len);
        if (qfp->qf_end_col > 0 && qfp->qf_col != qfp->qf_end_col)
        {
-           vim_snprintf((char *)buf + len, bufsize - len,
-                   "-%d", qfp->qf_end_col);
+           vim_snprintf((char *)buf + len, bufsize - len, "-%d",
+                                                             qfp->qf_end_col);
            len += (int)STRLEN(buf + len);
        }
     }
-    buf[len] = NUL;
 
     ga_concat_len(gap, buf, len);
 }
@@ -4659,7 +4656,6 @@ qf_buf_add_line(
     if (qftf_str != NULL && *qftf_str != NUL)
     {
        ga_concat(gap, qftf_str);
-       ga_append(gap, NUL);
     }
     else
     {
@@ -4706,6 +4702,7 @@ qf_buf_add_line(
                                                               : qfp->qf_text);
     }
 
+    ga_append(gap, NUL);
     if (ml_append_buf(buf, lnum, gap->ga_data, gap->ga_len, FALSE) == FAIL)
        return FAIL;
 
index 7e4a0482586a981c7f7d6895665cb515d0348e2a..b7d290275ba6b38f2d2eb1d97926dd8f4c8f20b6 100644 (file)
@@ -167,13 +167,15 @@ func XlistTests(cchar)
              \ {'lnum':20,'col':10,'type':'e','text':'Error','nr':22},
              \ {'lnum':30,'col':15,'type':'i','text':'Info','nr':33},
              \ {'lnum':40,'col':20,'type':'x', 'text':'Other','nr':44},
-             \ {'lnum':50,'col':25,'type':"\<C-A>",'text':'one','nr':55}])
+             \ {'lnum':50,'col':25,'type':"\<C-A>",'text':'one','nr':55},
+             \ {'lnum':0,'type':'e','text':'Check type field is output even when lnum==0. ("error" was not output by v9.0.0736.)','nr':66}])
   let l = split(execute('Xlist', ""), "\n")
   call assert_equal([' 1:10 col 5 warning  11: Warning',
              \ ' 2:20 col 10 error  22: Error',
              \ ' 3:30 col 15 info  33: Info',
              \ ' 4:40 col 20 x  44: Other',
-             \ ' 5:50 col 25  55: one'], l)
+             \ ' 5:50 col 25  55: one',
+              \ ' 6 error  66: Check type field is output even when lnum==0. ("error" was not output by v9.0.0736.)'], l)
 
   " Test for module names, one needs to explicitly set `'valid':v:true` so
   call g:Xsetlist([
@@ -6428,4 +6430,11 @@ func Test_setqflist_stopinsert()
   bwipe!
 endfunc
 
+func Test_quickfix_buffer_contents()
+  call setqflist([{'filename':'filename', 'pattern':'pattern', 'text':'text'}])
+  copen
+  call assert_equal(['filename|pattern| text'], getline(1, '$'))  " The assert failed with Vim v9.0.0736; '| text' did not appear after the pattern.
+  call setqflist([], 'f')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 4e94e4bc65b10a5de0b0c39fd6074a5603387588..e6858c2a2be7f9fca326adecf3b554a4b5988530 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1616,
 /**/
     1615,
 /**/