diff options
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/misc1.c b/src/misc1.c index 162864282..22dbfc872 100644 --- a/src/misc1.c +++ b/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. |