aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-07 10:17:19 +0800
committerGitHub <noreply@github.com>2023-06-07 10:17:19 +0800
commitfcaf0d5f3824431520a0b6353c771107cc63ed4e (patch)
tree3c4cd503d1e881b68feaa5c235906f6f9ca7949b /src/nvim/path.c
parent0e0a166a0cc5a2dc199136e313e58c27bfb91977 (diff)
parentdd24ea819507e3a5da04df55df7dda5240e5b57f (diff)
downloadrneovim-fcaf0d5f3824431520a0b6353c771107cc63ed4e.tar.gz
rneovim-fcaf0d5f3824431520a0b6353c771107cc63ed4e.tar.bz2
rneovim-fcaf0d5f3824431520a0b6353c771107cc63ed4e.zip
Merge pull request #23943 from zeertzjq/autocmd-fname
fix(events): don't expand non-file as file name
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c10
1 files changed, 5 insertions, 5 deletions
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