mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 02:46:31 +00:00
vim-patch:8.1.1371: cannot recover from a swap file #11081
Problem: Cannot recover from a swap file.
Solution: Do not expand environment variables in the swap file name.
Do not check the extension when we already know a file is a swap
file. (Ken Takata, closes 4415, closes vim/vim#4369)
99499b1c05
This commit is contained in:

committed by
Justin M. Keyes

parent
1396cc9abb
commit
fe074611cd
@@ -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
|
||||
@@ -1375,7 +1375,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.
|
||||
|
Reference in New Issue
Block a user