src/nvim/fileio.c
/// 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.
/// When "force" is FALSE: Only try to shorten absolute file names.
/// For buffers that have buftype "nofile" or "scratch": never change the file
/// name.
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.
When "force" is FALSE: Only try to shorten absolute file names.
For buffers that have buftype "nofile" or "scratch": never change the file
name.
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 . When " force " is FALSE : Only try to shorten absolute file names . 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_CLEAR(buf->b_sfname);
    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 = buf->b_ffname;
    }
  }
}
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_CLEAR ( buf -> b_sfname ) ; 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 = buf -> b_ffname ; } } }
Shorten filename of a buffer.
Shorten filename of a buffer .