From dd24ea819507e3a5da04df55df7dda5240e5b57f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Jun 2023 09:29:12 +0800 Subject: fix(events): don't expand non-file as file name --- src/nvim/autocmd.c | 1 + src/nvim/path.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 564a7b4f87..427bce0e80 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1676,6 +1676,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force || event == EVENT_USER || event == EVENT_WINCLOSED || event == EVENT_WINRESIZED || event == EVENT_WINSCROLLED) { fname = xstrdup(fname); + autocmd_fname_full = true; // don't expand it later } else { fname = FullName_save(fname, false); } diff --git a/src/nvim/path.c b/src/nvim/path.c index 21a3a67e24..ea0d5a8be1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -2087,17 +2087,17 @@ char *path_shorten_fname(char *full_path, char *dir_name) assert(dir_name != NULL); size_t len = strlen(dir_name); - // If dir_name is a path head, full_path can always be made relative. - if (len == (size_t)path_head_length() && is_path_head(dir_name)) { - return full_path + len; - } - // If full_path and dir_name do not match, it's impossible to make one // relative to the other. if (path_fnamencmp(dir_name, full_path, len) != 0) { return NULL; } + // If dir_name is a path head, full_path can always be made relative. + if (len == (size_t)path_head_length() && is_path_head(dir_name)) { + return full_path + len; + } + char *p = full_path + len; // If *p is not pointing to a path separator, this means that full_path's -- cgit