0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.0303: line2byte() is wrong for last line with 'noeol'

Problem:    line2byte() is wrong for last line with 'noeol' and 'nofixeol'.
Solution:   Fix off-by-one error. (Shane Harper, closes #3351)
This commit is contained in:
Bram Moolenaar
2018-08-20 22:53:04 +02:00
parent f1883479be
commit c26f7c6053
3 changed files with 14 additions and 2 deletions

View File

@@ -682,6 +682,7 @@ endfunc
func Test_byte2line_line2byte()
new
set endofline
call setline(1, ['a', 'bc', 'd'])
set fileformat=unix
@@ -702,7 +703,16 @@ func Test_byte2line_line2byte()
call assert_equal([-1, -1, 1, 4, 8, 11, -1],
\ map(range(-1, 5), 'line2byte(v:val)'))
set fileformat&
bw!
set noendofline nofixendofline
normal a-
for ff in ["unix", "mac", "dos"]
let &fileformat = ff
call assert_equal(1, line2byte(1))
call assert_equal(2, line2byte(2)) " line2byte(line("$") + 1) is the buffer size plus one (as per :help line2byte).
endfor
set endofline& fixendofline& fileformat&
bw!
endfunc