aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-10-30 07:10:04 +0800
committerGitHub <noreply@github.com>2022-10-30 07:10:04 +0800
commitf2d9c330fc56d1e589d33c82d372532e1695ce40 (patch)
treefbbb2007fab138820b2443916fd11b8c61c2ebd9 /src
parenta7d100f052b45a106d1385ed419509c047c12431 (diff)
downloadrneovim-f2d9c330fc56d1e589d33c82d372532e1695ce40.tar.gz
rneovim-f2d9c330fc56d1e589d33c82d372532e1695ce40.tar.bz2
rneovim-f2d9c330fc56d1e589d33c82d372532e1695ce40.zip
fix(path): don't remove trailing slash when getting absolute path (#20853)
Before Vim patch 8.2.3468 relative_directory is never used in the resulting path name, so whether it has a trailing slash didn't matter. Now path_full_dir_name() appends a non-existing relative directory to the current directory name, so the trailing slash needs to be kept.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/path.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 981937b79e..625a3c7922 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2362,16 +2362,9 @@ static int path_to_absolute(const char *fname, char *buf, size_t len, int force)
}
#endif
if (p != NULL) {
- // relative to root
- if (p == fname) {
- // only one path component
- relative_directory[0] = PATHSEP;
- relative_directory[1] = NUL;
- } else {
- assert(p >= fname);
- memcpy(relative_directory, fname, (size_t)(p - fname));
- relative_directory[p - fname] = NUL;
- }
+ assert(p >= fname);
+ memcpy(relative_directory, fname, (size_t)(p - fname + 1));
+ relative_directory[p - fname + 1] = NUL;
end_of_path = p + 1;
} else {
relative_directory[0] = NUL;