To reproduce problem:
1. Create file bad.tmp by executing the following line.
:call writefile(["Very important file \x8D"], 'bad.tmp')
2. Start Vim editing the file and enter commands, as below.
vim -N -u NONE bad.tmp
:set fenc=cp857
:set nobackup nowritebackup
:w
3. Observe message which you have probably never seen before:
"bad.tmp" E513: write error, conversion failed
(make 'fenc' empty to override)
WARNING: Original file may be lost or damaged
don't quit the editor until the file is successfully written!
4. Panic and do what has always worked in the past:
:q!
Result:
- Step 2 replaces bad.tmp with an empty file.
- The original contents have been lost.
The "no backup" options cause Vim to overwrite the existing
file. However, the write aborts when the conversion fails,
resulting in lost data.
While a user should not turn off backups on an important file,
it is a horrible trap that one incorrect byte can effectively
delete a file.
A message like the following might help:
"bad.tmp" E513: write error, conversion failed
WARNING: The file on disk has probably been corrupted.
Do not quit until the file is successfully written!
Try saving it again after entering (nothing after "="):
:set fenc=
I haven't done more than glance at Christian Brabandt's patch
so I don't know what is achievable. Would something as simple
as checking the number of bytes in the file on disk be
sufficient to decide if corrective action is needed?
John
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php