Mercurial > vim
comparison src/testdir/test_fixeol.vim @ 30982:92b1338023ee v9.0.0826
patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Commit: https://github.com/vim/vim/commit/3af982196b1b973e953c35351961f2a96fe34172
Author: K.Takata <kentkt@csc.jp>
Date: Tue Nov 1 20:36:19 2022 +0000
patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 02 Nov 2022 11:18:57 +0100 |
parents | 35265d9d24df |
children |
comparison
equal
deleted
inserted
replaced
30981:bc0c516efae9 | 30982:92b1338023ee |
---|---|
46 call delete('XXTestNoEol') | 46 call delete('XXTestNoEol') |
47 set ff& fixeol& eof& eol& | 47 set ff& fixeol& eof& eol& |
48 enew! | 48 enew! |
49 endfunc | 49 endfunc |
50 | 50 |
51 func Test_eof() | |
52 let data = 0z68656c6c6f.0d0a.776f726c64 " "hello\r\nworld" | |
53 | |
54 " 1. Eol, Eof | |
55 " read | |
56 call writefile(data + 0z0d0a.1a, 'XXEolEof') | |
57 e! XXEolEof | |
58 call assert_equal(['hello', 'world'], getline(1, 2)) | |
59 call assert_equal([1, 1], [&eol, &eof]) | |
60 " write | |
61 set fixeol | |
62 w! | |
63 call assert_equal(data + 0z0d0a, readblob('XXEolEof')) | |
64 set nofixeol | |
65 w! | |
66 call assert_equal(data + 0z0d0a.1a, readblob('XXEolEof')) | |
67 | |
68 " 2. NoEol, Eof | |
69 " read | |
70 call writefile(data + 0z1a, 'XXNoEolEof') | |
71 e! XXNoEolEof | |
72 call assert_equal(['hello', 'world'], getline(1, 2)) | |
73 call assert_equal([0, 1], [&eol, &eof]) | |
74 " write | |
75 set fixeol | |
76 w! | |
77 call assert_equal(data + 0z0d0a, readblob('XXNoEolEof')) | |
78 set nofixeol | |
79 w! | |
80 call assert_equal(data + 0z1a, readblob('XXNoEolEof')) | |
81 | |
82 " 3. Eol, NoEof | |
83 " read | |
84 call writefile(data + 0z0d0a, 'XXEolNoEof') | |
85 e! XXEolNoEof | |
86 call assert_equal(['hello', 'world'], getline(1, 2)) | |
87 call assert_equal([1, 0], [&eol, &eof]) | |
88 " write | |
89 set fixeol | |
90 w! | |
91 call assert_equal(data + 0z0d0a, readblob('XXEolNoEof')) | |
92 set nofixeol | |
93 w! | |
94 call assert_equal(data + 0z0d0a, readblob('XXEolNoEof')) | |
95 | |
96 " 4. NoEol, NoEof | |
97 " read | |
98 call writefile(data, 'XXNoEolNoEof') | |
99 e! XXNoEolNoEof | |
100 call assert_equal(['hello', 'world'], getline(1, 2)) | |
101 call assert_equal([0, 0], [&eol, &eof]) | |
102 " write | |
103 set fixeol | |
104 w! | |
105 call assert_equal(data + 0z0d0a, readblob('XXNoEolNoEof')) | |
106 set nofixeol | |
107 w! | |
108 call assert_equal(data, readblob('XXNoEolNoEof')) | |
109 | |
110 call delete('XXEolEof') | |
111 call delete('XXNoEolEof') | |
112 call delete('XXEolNoEof') | |
113 call delete('XXNoEolNoEof') | |
114 set ff& fixeol& eof& eol& | |
115 enew! | |
116 endfunc | |
117 | |
51 " vim: shiftwidth=2 sts=2 expandtab | 118 " vim: shiftwidth=2 sts=2 expandtab |