Mercurial > vim
comparison src/fileio.c @ 13819:31bb8e1f7625 v8.0.1781
patch 8.0.1781: file names in quickfix window are not shortened
commit https://github.com/vim/vim/commit/a796d46f29e3cc235cc981696d7ee80faccb5000
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 1 14:30:36 2018 +0200
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 #2851, closes #2846)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 01 May 2018 14:45:05 +0200 |
parents | cad480bac9e1 |
children | 68290d296dc9 |
comparison
equal
deleted
inserted
replaced
13818:28ac7914b2b6 | 13819:31bb8e1f7625 |
---|---|
6161 p = NULL; | 6161 p = NULL; |
6162 return p; | 6162 return p; |
6163 } | 6163 } |
6164 | 6164 |
6165 /* | 6165 /* |
6166 * Shorten filenames for all buffers. | 6166 * Shorten filename of a buffer. |
6167 * When "force" is TRUE: Use full path from now on for files currently being | 6167 * When "force" is TRUE: Use full path from now on for files currently being |
6168 * edited, both for file name and swap file name. Try to shorten the file | 6168 * edited, both for file name and swap file name. Try to shorten the file |
6169 * names a bit, if safe to do so. | 6169 * names a bit, if safe to do so. |
6170 * When "force" is FALSE: Only try to shorten absolute file names. | 6170 * When "force" is FALSE: Only try to shorten absolute file names. |
6171 * For buffers that have buftype "nofile" or "scratch": never change the file | 6171 * For buffers that have buftype "nofile" or "scratch": never change the file |
6172 * name. | 6172 * name. |
6173 */ | 6173 */ |
6174 void | 6174 void |
6175 shorten_buf_fname(buf_T *buf, char_u *dirname, int force) | |
6176 { | |
6177 char_u *p; | |
6178 | |
6179 if (buf->b_fname != NULL | |
6180 #ifdef FEAT_QUICKFIX | |
6181 && !bt_nofile(buf) | |
6182 #endif | |
6183 && !path_with_url(buf->b_fname) | |
6184 && (force | |
6185 || buf->b_sfname == NULL | |
6186 || mch_isFullName(buf->b_sfname))) | |
6187 { | |
6188 VIM_CLEAR(buf->b_sfname); | |
6189 p = shorten_fname(buf->b_ffname, dirname); | |
6190 if (p != NULL) | |
6191 { | |
6192 buf->b_sfname = vim_strsave(p); | |
6193 buf->b_fname = buf->b_sfname; | |
6194 } | |
6195 if (p == NULL || buf->b_fname == NULL) | |
6196 buf->b_fname = buf->b_ffname; | |
6197 } | |
6198 } | |
6199 | |
6200 /* | |
6201 * Shorten filenames for all buffers. | |
6202 */ | |
6203 void | |
6175 shorten_fnames(int force) | 6204 shorten_fnames(int force) |
6176 { | 6205 { |
6177 char_u dirname[MAXPATHL]; | 6206 char_u dirname[MAXPATHL]; |
6178 buf_T *buf; | 6207 buf_T *buf; |
6179 char_u *p; | |
6180 | 6208 |
6181 mch_dirname(dirname, MAXPATHL); | 6209 mch_dirname(dirname, MAXPATHL); |
6182 FOR_ALL_BUFFERS(buf) | 6210 FOR_ALL_BUFFERS(buf) |
6183 { | 6211 { |
6184 if (buf->b_fname != NULL | 6212 shorten_buf_fname(buf, dirname, force); |
6185 #ifdef FEAT_QUICKFIX | |
6186 && !bt_nofile(buf) | |
6187 #endif | |
6188 && !path_with_url(buf->b_fname) | |
6189 && (force | |
6190 || buf->b_sfname == NULL | |
6191 || mch_isFullName(buf->b_sfname))) | |
6192 { | |
6193 VIM_CLEAR(buf->b_sfname); | |
6194 p = shorten_fname(buf->b_ffname, dirname); | |
6195 if (p != NULL) | |
6196 { | |
6197 buf->b_sfname = vim_strsave(p); | |
6198 buf->b_fname = buf->b_sfname; | |
6199 } | |
6200 if (p == NULL || buf->b_fname == NULL) | |
6201 buf->b_fname = buf->b_ffname; | |
6202 } | |
6203 | 6213 |
6204 /* Always make the swap file name a full path, a "nofile" buffer may | 6214 /* Always make the swap file name a full path, a "nofile" buffer may |
6205 * also have a swap file. */ | 6215 * also have a swap file. */ |
6206 mf_fullname(buf->b_ml.ml_mfp); | 6216 mf_fullname(buf->b_ml.ml_mfp); |
6207 } | 6217 } |