summaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-05-01 14:30:36 +0200
committerBram Moolenaar <Bram@vim.org>2018-05-01 14:30:36 +0200
commita796d46f29e3cc235cc981696d7ee80faccb5000 (patch)
tree542906c6f700a59c60ad6dcd203be8d75dd66643 /src/fileio.c
parent15142e27aaafa15b72d1042c25fbb5e4f12b6736 (diff)
patch 8.0.1781: file names in quickfix window are not shortenedv8.0.1781
Problem: File names in quickfix window are not always shortened. Solution: Shorten the file name when opening the quickfix window. (Yegappan Lakshmanan, closes #2851, closes #2846)
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 63cc61c432..98631e074a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6163,7 +6163,7 @@ shorten_fname(char_u *full_path, char_u *dir_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.
@@ -6172,34 +6172,44 @@ shorten_fname(char_u *full_path, char_u *dir_name)
* name.
*/
void
+shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
+{
+ char_u *p;
+
+ if (buf->b_fname != NULL
+#ifdef FEAT_QUICKFIX
+ && !bt_nofile(buf)
+#endif
+ && !path_with_url(buf->b_fname)
+ && (force
+ || buf->b_sfname == NULL
+ || mch_isFullName(buf->b_sfname)))
+ {
+ VIM_CLEAR(buf->b_sfname);
+ p = 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];
buf_T *buf;
- char_u *p;
mch_dirname(dirname, MAXPATHL);
FOR_ALL_BUFFERS(buf)
{
- if (buf->b_fname != NULL
-#ifdef FEAT_QUICKFIX
- && !bt_nofile(buf)
-#endif
- && !path_with_url(buf->b_fname)
- && (force
- || buf->b_sfname == NULL
- || mch_isFullName(buf->b_sfname)))
- {
- VIM_CLEAR(buf->b_sfname);
- p = 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. */