mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
vim-patch:9.0.0816: CTRL-Z at end of file is always dropped
Problem: CTRL-Z at end of file is always dropped. Solution: Add the 'endoffile' option, like the 'endofline' option. (closes vim/vim#11408, closes vim/vim#11397) Cherry-pick test_fixeol.vim changes from patch 8.2.1432. Cherry-pick 'endoffile' changes from latest Vim runtime update.fb0cf2357e
vim-patch:f0b567e32a46 Revert unintended Makefile changef0b567e32a
vim-patch:72c8e3c070b3 Fix wrong struct access for member.72c8e3c070
vim-patch:3f68a4136eb9 Add missing entry for the 'endoffile' option.3f68a4136e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -525,6 +525,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
|
||||
// correctly set when reading stdin.
|
||||
if (!read_buffer) {
|
||||
curbuf->b_p_eol = true;
|
||||
curbuf->b_p_eof = false;
|
||||
curbuf->b_start_eol = true;
|
||||
}
|
||||
curbuf->b_p_bomb = false;
|
||||
@@ -1629,12 +1630,13 @@ failed:
|
||||
&& !got_int
|
||||
&& linerest != 0
|
||||
&& !(!curbuf->b_p_bin
|
||||
&& fileformat == EOL_DOS
|
||||
&& *line_start == Ctrl_Z
|
||||
&& ptr == line_start + 1)) {
|
||||
&& fileformat == EOL_DOS)) {
|
||||
// remember for when writing
|
||||
if (set_options) {
|
||||
curbuf->b_p_eol = false;
|
||||
if (*line_start == Ctrl_Z && ptr == line_start + 1) {
|
||||
curbuf->b_p_eof = false;
|
||||
}
|
||||
}
|
||||
*ptr = NUL;
|
||||
len = (colnr_T)(ptr - line_start + 1);
|
||||
@@ -3191,6 +3193,11 @@ restore_backup:
|
||||
len = 0;
|
||||
write_info.bw_start_lnum = lnum;
|
||||
}
|
||||
if (!buf->b_p_fixeol && buf->b_p_eof) {
|
||||
// write trailing CTRL-Z
|
||||
(void)write_eintr(write_info.bw_fd, "\x1a", 1);
|
||||
}
|
||||
|
||||
// write failed or last line has no EOL: stop here
|
||||
if (end == 0
|
||||
|| (lnum == end
|
||||
|
Reference in New Issue
Block a user