diff options
| author | ckelsel <ckelsel@hotmail.com> | 2018-09-07 20:38:25 +0800 |
|---|---|---|
| committer | James McCoy <jamessan@jamessan.com> | 2018-10-12 19:49:14 -0400 |
| commit | aeda13cfdf80b64c48313cbe6abd2ff028431808 (patch) | |
| tree | 21548869b91ad1868802c3cbec2edbca6c568f51 /src/nvim/testdir | |
| parent | 384770556ba02433904baf78f499b9bb48010040 (diff) | |
| download | rneovim-aeda13cfdf80b64c48313cbe6abd2ff028431808.tar.gz rneovim-aeda13cfdf80b64c48313cbe6abd2ff028431808.tar.bz2 rneovim-aeda13cfdf80b64c48313cbe6abd2ff028431808.zip | |
vim-patch:8.0.0685: when conversion fails written file may be truncated
Problem: When making backups is disabled and conversion with iconv fails
the written file is truncated. (Luo Chen)
Solution: First try converting the file and write the file only when it did
not fail. (partly by Christian Brabandt)
https://github.com/vim/vim/commit/e6bf655bc4de1b7f4586e1f5c2fc4978141c3aa3
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_writefile.vim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index 06f9d03554..1cd5fb306a 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -32,6 +32,24 @@ func Test_writefile_fails_gently() call assert_fails('call writefile([], [])', 'E730:') endfunc +func Test_writefile_fails_conversion() + if !has('multi_byte') || !has('iconv') + return + endif + set nobackup nowritebackup + new + let contents = ["line one", "line two"] + call writefile(contents, 'Xfile') + edit Xfile + call setline(1, ["first line", "cannot convert \u010b", "third line"]) + call assert_fails('write ++enc=cp932') + call assert_equal(contents, readfile('Xfile')) + + call delete('Xfile') + bwipe! + set backup& writebackup& +endfunc + func SetFlag(timer) let g:flag = 1 endfunc |