diff options
author | K.Takata <kentkt@csc.jp> | 2022-11-01 20:36:19 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-11-01 20:36:19 +0000 |
commit | 3af982196b1b973e953c35351961f2a96fe34172 (patch) | |
tree | 8b2bc31d033187b17b4c5fb6e51350f833cd984b /src/bufwrite.c | |
parent | 8e0ccb6bc21a446e5c6375b7fdf200fb53a129da (diff) |
patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong placev9.0.0826
Problem: If 'endofline' is set the CTRL-Z may be written in the wrong
place.
Solution: Write CTRL-Z at the end of the file. Update the help to explain
the possibilities better. (Ken Takata, closes #11486)
Diffstat (limited to 'src/bufwrite.c')
-rw-r--r-- | src/bufwrite.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c index 12c5c7a474..f3adcc3e8e 100644 --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -2050,10 +2050,6 @@ 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 @@ -2158,6 +2154,13 @@ restore_backup: nchars += len; } + if (!buf->b_p_fixeol && buf->b_p_eof) + { + // write trailing CTRL-Z + (void)write_eintr(write_info.bw_fd, "\x1a", 1); + nchars++; + } + // Stop when writing done or an error was encountered. if (!checking_conversion || end == 0) break; |