aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/path.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-11-21 17:47:09 -0500
committerGitHub <noreply@github.com>2021-11-21 17:47:09 -0500
commit0d967f0298a355452f62b9c76c34e102a6b9016e (patch)
tree467949d95f8bb1791a31c7439846bf6d2755d3e1 /src/nvim/path.c
parentd99d4af7b129032865cb5a4fd8e6999e73460fb0 (diff)
parent349b9ce9df0c7f48ce236216ab0d2c507f483425 (diff)
downloadrneovim-0d967f0298a355452f62b9c76c34e102a6b9016e.tar.gz
rneovim-0d967f0298a355452f62b9c76c34e102a6b9016e.tar.bz2
rneovim-0d967f0298a355452f62b9c76c34e102a6b9016e.zip
Merge pull request #16362 from zeertzjq/vim-8.2.3617
vim-patch:8.2.{3468,3617,3618,3622}: some other CWD related patches
Diffstat (limited to 'src/nvim/path.c')
-rw-r--r--src/nvim/path.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 19c820e4dd..7b9081eafa 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2245,11 +2245,17 @@ int path_full_dir_name(char *directory, char *buffer, size_t len)
}
if (os_chdir(directory) != SUCCESS) {
- // Do not return immediately since we may be in the wrong directory.
- retval = FAIL;
- }
-
- if (retval == FAIL || os_dirname((char_u *)buffer, len) == FAIL) {
+ // Path does not exist (yet). For a full path fail,
+ // will use the path as-is. For a relative path use
+ // the current directory and append the file name.
+ if (path_is_absolute((const char_u *)directory)) {
+ // Do not return immediately since we may be in the wrong directory.
+ retval = FAIL;
+ } else {
+ xstrlcpy(buffer, old_dir, len);
+ append_path(buffer, directory, len);
+ }
+ } else if (os_dirname((char_u *)buffer, len) == FAIL) {
// Do not return immediately since we are in the wrong directory.
retval = FAIL;
}