mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2199: first write after setting 'eol' does not have NL added
Problem: First write after setting 'eol' does not have NL added. (Tomáš
Janoušek)
Solution: Only use b_no_eol_lnum when doing a binary write. (closes vim/vim#7535)
b3c8b1d254
This commit is contained in:
parent
92e4394562
commit
47a98ab394
@ -3318,7 +3318,7 @@ restore_backup:
|
||||
if (end == 0
|
||||
|| (lnum == end
|
||||
&& (write_bin || !buf->b_p_fixeol)
|
||||
&& (lnum == buf->b_no_eol_lnum
|
||||
&& ((write_bin && lnum == buf->b_no_eol_lnum)
|
||||
|| (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol)))) {
|
||||
lnum++; // written the line, count it
|
||||
no_eol = true;
|
||||
|
@ -497,6 +497,24 @@ func Test_readwrite_file_with_bom()
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
func Test_read_write_bin()
|
||||
" write file missing EOL
|
||||
call writefile(['noeol'], "XNoEolSetEol", 'bS')
|
||||
call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B'))
|
||||
|
||||
" when file is read 'eol' is off
|
||||
set ff=unix nofixeol
|
||||
e XNoEolSetEol
|
||||
call assert_equal(0, &eol)
|
||||
|
||||
" writing with 'eol' set adds the newline
|
||||
setlocal eol
|
||||
w
|
||||
call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
|
||||
|
||||
call delete('XNoEolSetEol')
|
||||
endfunc
|
||||
|
||||
" Check that buffer is written before triggering QuitPre
|
||||
func Test_wq_quitpre_autocommand()
|
||||
edit Xsomefile
|
||||
|
Loading…
Reference in New Issue
Block a user