]> granicus.if.org Git - vim/commitdiff
patch 9.0.0097: long quickfix line is truncated for :clist v9.0.0097
authorBram Moolenaar <Bram@vim.org>
Thu, 28 Jul 2022 10:56:01 +0000 (11:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 28 Jul 2022 10:56:01 +0000 (11:56 +0100)
Problem:    Long quickfix line is truncated for :clist.
Solution:   Allocate a buffer if needed.

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

index 49484e0602a13d8d03b59e9fa65d6e5fd015048a..b9b908cc064e8421e6fa46d3c827c383a69447d0 100644 (file)
@@ -3622,13 +3622,31 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
     }
     msg_puts(" ");
 
-    // Remove newlines and leading whitespace from the text.  For an
-    // unrecognized line keep the indent, the compiler may mark a word
-    // with ^^^^.
-    qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
-                               ? skipwhite(qfp->qf_text) : qfp->qf_text,
-                               IObuff, IOSIZE);
-    msg_prt_line(IObuff, FALSE);
+    {
+       char_u *tbuf = IObuff;
+       size_t  tbuflen = IOSIZE;
+       size_t  len = STRLEN(qfp->qf_text) + 3;
+
+       if (len > IOSIZE)
+       {
+           tbuf = alloc(len);
+           if (tbuf != NULL)
+               tbuflen = len;
+           else
+               tbuf = IObuff;
+       }
+
+       // Remove newlines and leading whitespace from the text.  For an
+       // unrecognized line keep the indent, the compiler may mark a word
+       // with ^^^^.
+       qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
+                                   ? skipwhite(qfp->qf_text) : qfp->qf_text,
+                                   tbuf, tbuflen);
+       msg_prt_line(tbuf, FALSE);
+
+       if (tbuf != IObuff)
+           vim_free(tbuf);
+    }
     out_flush();               // show one line at a time
 }
 
index 2431a46fc9c737f0125ff9fb5ab4ee0244dc1851..94651af81942349eb5e09a65ba26f5e76786ecfd 100644 (file)
@@ -185,6 +185,14 @@ func XlistTests(cchar)
        \ ' 2 Data.Text:20 col 10 warning  22: ModuleWarning',
        \ ' 3 Data/Text.hs:30 col 15 warning  33: FileWarning'], l)
 
+  " Very long line should be displayed.
+  let text = 'Line' .. repeat('1234567890', 130)
+  let lines = ['Xtestfile9:2:9:' .. text]
+  Xgetexpr lines
+
+  let l = split(execute('Xlist', ''), "\n")
+  call assert_equal([' 1 Xtestfile9:2 col 9: ' .. text] , l)
+
   " For help entries in the quickfix list, only the filename without directory
   " should be displayed
   Xhelpgrep setqflist()
index 967f7aa0035e62387341f7e2594f71062d01786b..08152ad0cf02048add2dd62a05c2a57782b08758 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    97,
 /**/
     96,
 /**/