Mercurial > vim
diff src/testdir/test_textprop.vim @ 15335:18c20ceee4b5 v8.1.0675
patch 8.1.0675: text property column in screen columns is not practical
commit https://github.com/vim/vim/commit/b9c67a51c15481d9257e5c26581d17780e9808d5
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 1 19:49:20 2019 +0100
patch 8.1.0675: text property column in screen columns is not practical
Problem: Text property column is screen columns is not practical.
Solution: Use byte values for the column.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Jan 2019 20:00:07 +0100 |
parents | f58e7895cb40 |
children | 03a7a9fdb792 |
line wrap: on
line diff
--- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -7,6 +7,8 @@ endif source screendump.vim +" test length zero + func Test_proptype_global() call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1}) let proptypes = prop_type_list() @@ -112,6 +114,12 @@ func Test_prop_add() 1del call assert_equal(s:expected_props, prop_list(1)) + " Prop without length or end column is zero length + call prop_clear(1) + call prop_add(1, 5, {'type': 'two'}) + let expected = [{'col': 5, 'length': 0, 'type': 'two', 'id': 0, 'start': 1, 'end': 1}] + call assert_equal(expected, prop_list(1)) + call DeletePropTypes() bwipe! endfunc @@ -220,7 +228,7 @@ func Test_prop_multiline() call assert_equal([expect1], prop_list(1)) let expect2 = {'col': 1, 'length': 10, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0} call assert_equal([expect2], prop_list(2)) - let expect3 = {'col': 1, 'length': 5, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} + let expect3 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} call assert_equal([expect3], prop_list(3)) call prop_clear(1, 3) @@ -236,30 +244,31 @@ func Test_prop_multiline() bwipe! - " Test deleting the first line with a prop. + " Test deleting the first line of a multi-line prop. call Setup_three_line_prop() + let expect_short = {'col': 2, 'length': 1, 'type': 'comment', 'start': 1, 'end': 1, 'id': 0} + call assert_equal([expect_short], prop_list(1)) let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} call assert_equal([expect2], prop_list(2)) 2del - let expect_short = {'col': 2, 'length': 1, 'type': 'comment', 'start': 1, 'end': 1, 'id': 0} call assert_equal([expect_short], prop_list(1)) let expect2 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} call assert_equal([expect2], prop_list(2)) bwipe! - " Test deleting the last line with a prop. + " Test deleting the last line of a multi-line prop. call Setup_three_line_prop() let expect3 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 0, 'end': 0, 'id': 0} call assert_equal([expect3], prop_list(3)) - let expect4 = {'col': 1, 'length': 5, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} + let expect4 = {'col': 1, 'length': 4, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} call assert_equal([expect4], prop_list(4)) 4del - let expect3 = {'col': 1, 'length': 6, 'type': 'comment', 'start': 0, 'end': 1, 'id': 0} + let expect3.end = 1 call assert_equal([expect3], prop_list(3)) call assert_equal([expect_short], prop_list(4)) bwipe! - " Test appending a line below the text prop start. + " Test appending a line below the multi-line text prop start. call Setup_three_line_prop() let expect2 = {'col': 4, 'length': 4, 'type': 'comment', 'start': 1, 'end': 0, 'id': 0} call assert_equal([expect2], prop_list(2)) @@ -287,22 +296,23 @@ endfunc " screenshot test with textprop highlighting funct Test_textprop_screenshots() - if !CanRunVimInTerminal() + if !CanRunVimInTerminal() || &encoding != 'utf-8' return endif call writefile([ - \ "call setline(1, ['One two', 'Number 123 and then 4567.', 'Three'])", + \ "call setline(1, ['One two', 'Numbér 123 änd thœn 4¾7.', 'Three'])", \ "hi NumberProp ctermfg=blue", \ "hi LongProp ctermbg=yellow", \ "call prop_type_add('number', {'highlight': 'NumberProp'})", \ "call prop_type_add('long', {'highlight': 'LongProp'})", \ "call prop_add(1, 4, {'end_lnum': 3, 'end_col': 3, 'type': 'long'})", - \ "call prop_add(2, 8, {'length': 3, 'type': 'number'})", - \ "call prop_add(2, 21, {'length': 4, 'type': 'number'})", + \ "call prop_add(2, 9, {'length': 3, 'type': 'number'})", + \ "call prop_add(2, 24, {'length': 4, 'type': 'number'})", \ "set number", + \ "hi clear SpellBad", \ "set spell", \], 'XtestProp') - let buf = RunVimInTerminal('-S XtestProp', {}) + let buf = RunVimInTerminal('-S XtestProp', {'rows': 6}) call VerifyScreenDump(buf, 'Test_textprop_01', {}) " clean up