comparison src/testdir/test_functions.vim @ 14579:23d6d9e9ae3e v8.1.0303

patch 8.1.0303: line2byte() is wrong for last line with 'noeol' commit https://github.com/vim/vim/commit/c26f7c60532a37a2bf0a5e69aa81081b440dfc38 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 20 22:53:04 2018 +0200 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 https://github.com/vim/vim/issues/3351)
author Christian Brabandt <cb@256bit.org>
date Mon, 20 Aug 2018 23:00:06 +0200
parents 336213a840d9
children 63d5ae57a663
comparison
equal deleted inserted replaced
14578:4e22895e5442 14579:23d6d9e9ae3e
680 bw! 680 bw!
681 endfunc 681 endfunc
682 682
683 func Test_byte2line_line2byte() 683 func Test_byte2line_line2byte()
684 new 684 new
685 set endofline
685 call setline(1, ['a', 'bc', 'd']) 686 call setline(1, ['a', 'bc', 'd'])
686 687
687 set fileformat=unix 688 set fileformat=unix
688 call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1], 689 call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
689 \ map(range(-1, 8), 'byte2line(v:val)')) 690 \ map(range(-1, 8), 'byte2line(v:val)'))
700 call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1], 701 call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1],
701 \ map(range(-1, 11), 'byte2line(v:val)')) 702 \ map(range(-1, 11), 'byte2line(v:val)'))
702 call assert_equal([-1, -1, 1, 4, 8, 11, -1], 703 call assert_equal([-1, -1, 1, 4, 8, 11, -1],
703 \ map(range(-1, 5), 'line2byte(v:val)')) 704 \ map(range(-1, 5), 'line2byte(v:val)'))
704 705
705 set fileformat& 706 bw!
707 set noendofline nofixendofline
708 normal a-
709 for ff in ["unix", "mac", "dos"]
710 let &fileformat = ff
711 call assert_equal(1, line2byte(1))
712 call assert_equal(2, line2byte(2)) " line2byte(line("$") + 1) is the buffer size plus one (as per :help line2byte).
713 endfor
714
715 set endofline& fixendofline& fileformat&
706 bw! 716 bw!
707 endfunc 717 endfunc
708 718
709 func Test_count() 719 func Test_count()
710 let l = ['a', 'a', 'A', 'b'] 720 let l = ['a', 'a', 'A', 'b']