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.
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index ad6fd09..fdf6045 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -7,6 +7,8 @@
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 @@
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 @@
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 @@
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 @@
" 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