diff options
author | Andrzej Pacanowski <andrzej.pacanowski@gmail.com> | 2018-09-07 17:22:52 +0200 |
---|---|---|
committer | Andrzej Pacanowski <andrzej.pacanowski@gmail.com> | 2018-09-10 06:45:13 +0200 |
commit | 0c80fead86cac10f97296b2ef14d52f0399cc845 (patch) | |
tree | 61e2f1cf0639be5d697db23e338e2fd89eec58c6 /src/nvim/fileio.c | |
parent | bbbed9fc6613c5b69d4ed471ff60d31246c03e35 (diff) | |
download | rneovim-0c80fead86cac10f97296b2ef14d52f0399cc845.tar.gz rneovim-0c80fead86cac10f97296b2ef14d52f0399cc845.tar.bz2 rneovim-0c80fead86cac10f97296b2ef14d52f0399cc845.zip |
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
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r-- | src/nvim/fileio.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 8b650d0d5b..494b557379 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -4312,7 +4312,7 @@ static int make_bom(char_u *buf, char_u *name) } /* - * Shorten filenames for all buffers. + * Shorten filename of a buffer. * When "force" is TRUE: Use full path from now on for files currently being * edited, both for file name and swap file name. Try to shorten the file * names a bit, if safe to do so. @@ -4320,29 +4320,38 @@ static int make_bom(char_u *buf, char_u *name) * For buffers that have buftype "nofile" or "scratch": never change the file * name. */ +void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) +{ + char_u *p; + + if (buf->b_fname != NULL + && !bt_nofile(buf) + && !path_with_url((char *)buf->b_fname) + && (force + || buf->b_sfname == NULL + || path_is_absolute(buf->b_sfname))) { + xfree(buf->b_sfname); + buf->b_sfname = NULL; + p = path_shorten_fname(buf->b_ffname, dirname); + if (p != NULL) { + buf->b_sfname = vim_strsave(p); + buf->b_fname = buf->b_sfname; + } + if (p == NULL || buf->b_fname == NULL) + buf->b_fname = buf->b_ffname; + } +} + +/* + * Shorten filenames for all buffers. + */ void shorten_fnames(int force) { char_u dirname[MAXPATHL]; - char_u *p; os_dirname(dirname, MAXPATHL); FOR_ALL_BUFFERS(buf) { - if (buf->b_fname != NULL - && !bt_nofile(buf) - && !path_with_url((char *)buf->b_fname) - && (force - || buf->b_sfname == NULL - || path_is_absolute(buf->b_sfname))) { - xfree(buf->b_sfname); - buf->b_sfname = NULL; - p = path_shorten_fname(buf->b_ffname, dirname); - if (p != NULL) { - buf->b_sfname = vim_strsave(p); - buf->b_fname = buf->b_sfname; - } - if (p == NULL || buf->b_fname == NULL) - buf->b_fname = buf->b_ffname; - } + shorten_buf_fname(buf, dirname, force); /* Always make the swap file name a full path, a "nofile" buffer may * also have a swap file. */ |