1
0
forked from aniani/vim

patch 8.1.1349: if writing runs into conversion error backup file is deleted

Problem:    If writing runs into a conversion error the backup file is
            deleted. (Arseny Nasokin)
Solution:   Don't delete the backup file is the file was overwritten and a
            conversion error occurred. (Christian Brabandt, closes #4387)
This commit is contained in:
Bram Moolenaar
2019-05-18 18:52:04 +02:00
parent f8191c5f07
commit cf0bfd9ade
3 changed files with 30 additions and 5 deletions

View File

@@ -4985,10 +4985,10 @@ restore_backup:
}
}
/*
* Remove the backup unless 'backup' option is set
*/
if (!p_bk && backup != NULL && mch_remove(backup) != 0)
// Remove the backup unless 'backup' option is set or there was a
// conversion error.
if (!p_bk && backup != NULL && !write_info.bw_conv_error
&& mch_remove(backup) != 0)
emsg(_("E207: Can't delete backup file"));
goto nofail;