linenr_T lnum,
qfline_T *qfp,
char_u *dirname,
+ int first_bufline,
char_u *qftf_str)
{
int len;
vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1);
else
{
- // shorten the file name if not done already
- if (errbuf->b_sfname == NULL
- || mch_isFullName(errbuf->b_sfname))
+ // Shorten the file name if not done already.
+ // For optimization, do this only for the first entry in a
+ // buffer.
+ if (first_bufline && (errbuf->b_sfname == NULL
+ || mch_isFullName(errbuf->b_sfname)))
{
if (*dirname == NUL)
mch_dirname(dirname, MAXPATHL);
{
char_u dirname[MAXPATHL];
int invalid_val = FALSE;
+ int prev_bufnr = -1;
*dirname = NUL;
invalid_val = TRUE;
}
- if (qf_buf_add_line(buf, lnum, qfp, dirname, qftf_str) == FAIL)
+ if (qf_buf_add_line(buf, lnum, qfp, dirname,
+ prev_bufnr != qfp->qf_fnum, qftf_str) == FAIL)
break;
+ prev_bufnr = qfp->qf_fnum;
++lnum;
qfp = qfp->qf_next;
if (qfp == NULL)
" Displaying the quickfix list should simplify the file path
silent! clist
call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
+ " Add a few entries for the same file with different paths and check whether
+ " the buffer name is shortened
+ %bwipe
+ call setqflist([], 'f')
+ call setqflist([{'filename' : 'test_quickfix.vim', 'lnum' : 10},
+ \ {'filename' : '../testdir/test_quickfix.vim', 'lnum' : 20},
+ \ {'filename' : fname, 'lnum' : 30}], ' ')
+ copen
+ call assert_equal(['test_quickfix.vim|10| ',
+ \ 'test_quickfix.vim|20| ',
+ \ 'test_quickfix.vim|30| '], getline(1, '$'))
+ cclose
endfunc
" Quickfix title tests