diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2021-08-27 18:08:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 18:08:20 -0700 |
commit | ff7f7dd26b45164a41dbc36799cb7b08ebb9f66b (patch) | |
tree | da748f3a399eab5083d9a077ad0c9faf31b3a8f8 /src/nvim/undo.c | |
parent | 32024787b6b1ef39c23bda1653c23b5dfbde9e81 (diff) | |
parent | e5d464d8e04e0745dfcbd9fc8b0e06d66cfffcbe (diff) | |
download | rneovim-ff7f7dd26b45164a41dbc36799cb7b08ebb9f66b.tar.gz rneovim-ff7f7dd26b45164a41dbc36799cb7b08ebb9f66b.tar.bz2 rneovim-ff7f7dd26b45164a41dbc36799cb7b08ebb9f66b.zip |
Merge #15433 defaults: auto-create backup dir
Diffstat (limited to 'src/nvim/undo.c')
-rw-r--r-- | src/nvim/undo.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c index e1a7dbb2d3..fb96d7e6ff 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -672,6 +672,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading) #ifdef HAVE_READLINK char fname_buf[MAXPATHL]; #endif + char *p; if (ffname == NULL) { return NULL; @@ -704,6 +705,13 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading) memmove(tail + tail_len + 1, ".un~", sizeof(".un~")); } else { dir_name[dir_len] = NUL; + + // Remove trailing pathseps from directory name + p = &dir_name[dir_len - 1]; + while (vim_ispathsep(*p)) { + *p-- = NUL; + } + bool has_directory = os_isdir((char_u *)dir_name); if (!has_directory && *dirp == NUL && !reading) { // Last directory in the list does not exist, create it. @@ -720,7 +728,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading) if (has_directory) { if (munged_name == NULL) { munged_name = xstrdup(ffname); - for (char *p = munged_name; *p != NUL; MB_PTR_ADV(p)) { + for (p = munged_name; *p != NUL; MB_PTR_ADV(p)) { if (vim_ispathsep(*p)) { *p = '%'; } |