summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-29 20:01:52 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-29 20:01:52 +0100
commit1577537f109d97a975fda9a899cacfb598617767 (patch)
tree2aae6eb208722a06a991f51a064ca9d135be175d
parent6ebe4f970b8b398087076a72a7aae6e680fb92da (diff)
patch 9.0.0819v9.0.0819
-rw-r--r--src/buffer.c2
-rw-r--r--src/change.c5
-rw-r--r--src/fileio.c10
-rw-r--r--src/structs.h1
-rw-r--r--src/testdir/test_fixeol.vim8
-rw-r--r--src/version.c2
6 files changed, 20 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 5a4825feb2..0714f62f81 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -790,6 +790,8 @@ buf_clear_file(buf_T *buf)
buf->b_ml.ml_line_count = 1;
unchanged(buf, TRUE, TRUE);
buf->b_shortname = FALSE;
+ buf->b_p_eof = FALSE;
+ buf->b_start_eof = FALSE;
buf->b_p_eol = TRUE;
buf->b_start_eol = TRUE;
buf->b_p_bomb = FALSE;
diff --git a/src/change.c b/src/change.c
index bb54edf6d0..bcdb703362 100644
--- a/src/change.c
+++ b/src/change.c
@@ -921,6 +921,7 @@ unchanged(buf_T *buf, int ff, int always_inc_changedtick)
save_file_ff(buf_T *buf)
{
buf->b_start_ffc = *buf->b_p_ff;
+ buf->b_start_eof = buf->b_p_eof;
buf->b_start_eol = buf->b_p_eol;
buf->b_start_bomb = buf->b_p_bomb;
@@ -955,7 +956,9 @@ file_ff_differs(buf_T *buf, int ignore_empty)
return FALSE;
if (buf->b_start_ffc != *buf->b_p_ff)
return TRUE;
- if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
+ if ((buf->b_p_bin || !buf->b_p_fixeol)
+ && (buf->b_start_eof != buf->b_p_eof
+ || buf->b_start_eol != buf->b_p_eol))
return TRUE;
if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
return TRUE;
diff --git a/src/fileio.c b/src/fileio.c
index ab867b7c8f..bca827152a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -589,8 +589,9 @@ readfile(
// correctly set when reading stdin.
if (!read_buffer)
{
- curbuf->b_p_eol = TRUE;
curbuf->b_p_eof = FALSE;
+ curbuf->b_start_eof = FALSE;
+ curbuf->b_p_eol = TRUE;
curbuf->b_start_eol = TRUE;
}
curbuf->b_p_bomb = FALSE;
@@ -2278,15 +2279,18 @@ failed:
if (!error
&& !got_int
&& linerest != 0
+ // TODO: should we handle CTRL-Z differently here for 'endoffile'?
&& !(!curbuf->b_p_bin
- && fileformat == EOL_DOS))
+ && fileformat == EOL_DOS
+ && *line_start == Ctrl_Z
+ && ptr == line_start + 1))
{
// 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;
+ curbuf->b_p_eof = TRUE;
}
*ptr = NUL;
len = (colnr_T)(ptr - line_start + 1);
diff --git a/src/structs.h b/src/structs.h
index 02c9c2adad..dfcdcfb188 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3150,6 +3150,7 @@ struct file_buffer
linenr_T b_no_eol_lnum; // non-zero lnum when last line of next binary
// write should not have an end-of-line
+ int b_start_eof; // last line had eof (CTRL-Z) when it was read
int b_start_eol; // last line had eol when it was read
int b_start_ffc; // first char of 'ff' when edit started
char_u *b_start_fenc; // 'fileencoding' when edit started or NULL
diff --git a/src/testdir/test_fixeol.vim b/src/testdir/test_fixeol.vim
index 3ede84f49e..9d6c900bdb 100644
--- a/src/testdir/test_fixeol.vim
+++ b/src/testdir/test_fixeol.vim
@@ -34,10 +34,10 @@ func Test_fixeol()
w >>XXTestEol
w >>XXTestNoEol
- call assert_equal(['with eol', 'END'], readfile('XXEol'))
- call assert_equal(['without eolEND'], readfile('XXNoEol'))
- call assert_equal(['with eol', 'stays eol', 'END'], readfile('XXTestEol'))
- call assert_equal(['without eol', 'stays withoutEND'],
+ call assert_equal(['with eol or eof', 'END'], readfile('XXEol'))
+ call assert_equal(['without eol or eofEND'], readfile('XXNoEol'))
+ call assert_equal(['with eol or eof', 'stays eol', 'END'], readfile('XXTestEol'))
+ call assert_equal(['without eol or eof', 'stays withoutEND'],
\ readfile('XXTestNoEol'))
call delete('XXEol')
diff --git a/src/version.c b/src/version.c
index ae48781af3..f9a00d632e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 819,
+/**/
818,
/**/
817,