From 0c80fead86cac10f97296b2ef14d52f0399cc845 Mon Sep 17 00:00:00 2001 From: Andrzej Pacanowski Date: Fri, 7 Sep 2018 17:22:52 +0200 Subject: vim-patch:8.0.1781: file names in quickfix window are not shortened Problem: File names in quickfix window are not always shortened. Solution: Shorten the file name when opening the quickfix window. (Yegappan Lakshmanan, closes vim/vim#2851, closes vim/vim#2846) https://github.com/vim/vim/commit/a796d46f29e3cc235cc981696d7ee80faccb5000 --- src/nvim/quickfix.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index ba2f2ba969..ab7e3ec6dd 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2240,6 +2240,9 @@ void qf_list(exarg_T *eap) } } + /* Shorten all the file names, so that it is easy to read */ + shorten_fnames(FALSE); + if (qi->qf_lists[qi->qf_curlist].qf_nonevalid) all = TRUE; qfp = qi->qf_lists[qi->qf_curlist].qf_start; @@ -2944,6 +2947,10 @@ static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) /* Check if there is anything to display */ if (qi->qf_curlist < qi->qf_listcount) { + char_u dirname[MAXPATHL]; + + *dirname = NUL; + // Add one line for each error if (old_last == NULL) { qfp = qi->qf_lists[qi->qf_curlist].qf_start; @@ -2959,6 +2966,14 @@ static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) if (qfp->qf_type == 1) { // :helpgrep STRLCPY(IObuff, path_tail(errbuf->b_fname), sizeof(IObuff)); } else { + /* shorten the file name if not done already */ + if (errbuf->b_sfname == NULL + || path_is_absolute(errbuf->b_sfname)) + { + if (*dirname == NUL) + os_dirname(dirname, MAXPATHL); + shorten_buf_fname(errbuf, dirname, FALSE); + } STRLCPY(IObuff, errbuf->b_fname, sizeof(IObuff)); } len = (int)STRLEN(IObuff); -- cgit