mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
vim-patch:8.2.3468: problem with :cd when editing file in non-existent directory
Problem: Problem with :cd when editing file in non-existent directory. (Yee
Cheng Chin)
Solution: Prepend the current directory to get the full path. (closes vim/vim#8903)
c6376c7984
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user