forked from aniani/vim
updated for version 7.0c10
This commit is contained in:
52
src/misc1.c
52
src/misc1.c
@@ -2437,7 +2437,10 @@ changed()
|
||||
{
|
||||
int save_msg_scroll = msg_scroll;
|
||||
|
||||
/* Give a warning about changing a read-only file. This may also
|
||||
* check-out the file, thus change "curbuf"! */
|
||||
change_warning(0);
|
||||
|
||||
/* Create a swap file if that is wanted.
|
||||
* Don't do this for "nofile" and "nowrite" buffer types. */
|
||||
if (curbuf->b_may_swap
|
||||
@@ -2913,7 +2916,9 @@ change_warning(col)
|
||||
&& curbuf->b_p_ro)
|
||||
{
|
||||
#ifdef FEAT_AUTOCMD
|
||||
++curbuf_lock;
|
||||
apply_autocmds(EVENT_FILECHANGEDRO, NULL, NULL, FALSE, curbuf);
|
||||
--curbuf_lock;
|
||||
if (!curbuf->b_p_ro)
|
||||
return;
|
||||
#endif
|
||||
@@ -4448,6 +4453,53 @@ vim_ispathlistsep(c)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_GUI_TABLINE) || defined(FEAT_WINDOWS) \
|
||||
|| defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
* Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname"
|
||||
* It's done in-place.
|
||||
*/
|
||||
void
|
||||
shorten_dir(str)
|
||||
char_u *str;
|
||||
{
|
||||
char_u *tail, *s, *d;
|
||||
int skip = FALSE;
|
||||
|
||||
tail = gettail(str);
|
||||
d = str;
|
||||
for (s = str; ; ++s)
|
||||
{
|
||||
if (s >= tail) /* copy the whole tail */
|
||||
{
|
||||
*d++ = *s;
|
||||
if (*s == NUL)
|
||||
break;
|
||||
}
|
||||
else if (vim_ispathsep(*s)) /* copy '/' and next char */
|
||||
{
|
||||
*d++ = *s;
|
||||
skip = FALSE;
|
||||
}
|
||||
else if (!skip)
|
||||
{
|
||||
*d++ = *s; /* copy next char */
|
||||
if (*s != '~' && *s != '.') /* and leading "~" and "." */
|
||||
skip = TRUE;
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
int l = mb_ptr2len(s);
|
||||
|
||||
while (--l > 0)
|
||||
*d++ = *s++;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return TRUE if the directory of "fname" exists, FALSE otherwise.
|
||||
* Also returns TRUE if there is no directory name.
|
||||
|
Reference in New Issue
Block a user