len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
- if (ptr[-1] == CAR) /* remove CR */
+ if (ptr > line_start && ptr[-1] == CAR)
{
+ /* remove CR before NL */
ptr[-1] = NUL;
--len;
}
endfunc
func Test_fileformat_autocommand()
- let filecnt = ["\<CR>", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
+ let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
let ffs = &ffs
call writefile(filecnt, 'Xfile', 'b')
au BufReadPre Xfile set ffs=dos ff=dos