diff options
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r-- | src/nvim/memline.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 15dd2767a2..e5ba17a0a7 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -523,9 +523,9 @@ void ml_open_file(buf_T *buf) } } - if (mfp->mf_fname == NULL) { /* Failed! */ - need_wait_return = TRUE; /* call wait_return later */ - ++no_wait_return; + if (*p_dir != NUL && mfp->mf_fname == NULL) { + need_wait_return = true; // call wait_return later + no_wait_return++; (void)EMSG2(_( "E303: Unable to open swap file for \"%s\", recovery impossible"), buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); @@ -540,7 +540,7 @@ void ml_open_file(buf_T *buf) /// file, or reading into an existing buffer, create a swap file now. /// /// @param newfile reading file into new buffer -void check_need_swap(int newfile) +void check_need_swap(bool newfile) { int old_msg_silent = msg_silent; // might be reset by an E325 message msg_silent = 0; // If swap dialog prompts for input, user needs to see it! @@ -738,10 +738,10 @@ static void add_b0_fenc(ZERO_BL *b0p, buf_T *buf) } -/* - * Try to recover curbuf from the .swp file. - */ -void ml_recover(void) +/// Try to recover curbuf from the .swp file. +/// @param checkext If true, check the extension and detect whether it is a +/// swap file. +void ml_recover(bool checkext) { buf_T *buf = NULL; memfile_T *mfp = NULL; @@ -785,7 +785,7 @@ void ml_recover(void) if (fname == NULL) /* When there is no file name */ fname = (char_u *)""; len = (int)STRLEN(fname); - if (len >= 4 + if (checkext && len >= 4 && STRNICMP(fname + len - 4, ".s", 2) == 0 && vim_strchr((char_u *)"abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL @@ -937,8 +937,9 @@ void ml_recover(void) */ if (directly) { expand_env(b0p->b0_fname, NameBuff, MAXPATHL); - if (setfname(curbuf, NameBuff, NULL, TRUE) == FAIL) + if (setfname(curbuf, NameBuff, NULL, true) == FAIL) { goto theend; + } } home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, TRUE); @@ -1375,7 +1376,9 @@ recover_names ( if (curbuf->b_ml.ml_mfp != NULL && (p = curbuf->b_ml.ml_mfp->mf_fname) != NULL) { for (int i = 0; i < num_files; i++) { - if (path_full_compare(p, files[i], true) & kEqualFiles) { + // Do not expand wildcards, on Windows would try to expand + // "%tmp%" in "%tmp%file" + if (path_full_compare(p, files[i], true, false) & kEqualFiles) { // Remove the name from files[i]. Move further entries // down. When the array becomes empty free it here, since // FreeWild() won't be called below. @@ -1435,7 +1438,7 @@ recover_names ( * Append the full path to name with path separators made into percent * signs, to dir. An unnamed buffer is handled as "" (<currentdir>/"") */ -static char *make_percent_swname(const char *dir, char *name) +char *make_percent_swname(const char *dir, char *name) FUNC_ATTR_NONNULL_ARG(1) { char *d = NULL; @@ -1927,6 +1930,7 @@ int ml_append_buf( colnr_T len, // length of new line, including NUL, or 0 bool newfile // flag, see above ) + FUNC_ATTR_NONNULL_ARG(1) { if (buf->b_ml.ml_mfp == NULL) return FAIL; |