diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-12-19 13:31:06 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-12-19 13:31:06 +0000 |
commit | 4ce1f99a2d58b809ab5a5c602bd031426f8527e8 (patch) | |
tree | 557dfdf60433feee20ea24ae7fc8fbde67e26c59 /src/testdir/test_textprop.vim | |
parent | 8efdcee02ed02cf9e51e1757441715c2479757ee (diff) |
patch 9.0.1077: can add text property with negative ID before virtual textv9.0.1077
Problem: Can add text property with negative ID before virtual text
property.
Solution: Remember that a text property with a negative ID was used and give
an appropriate error message. (closes #11725)
Fix index computation.
Diffstat (limited to 'src/testdir/test_textprop.vim')
-rw-r--r-- | src/testdir/test_textprop.vim | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 333c3b2c97..a507a952cf 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -3725,6 +3725,50 @@ func Test_text_prop_diff_mode() call StopVimInTerminal(buf) endfunc + +func Test_error_when_using_negative_id() + call prop_type_add('test1', #{highlight: 'ErrorMsg'}) + call prop_add(1, 1, #{type: 'test1', text: 'virtual'}) + call assert_fails("call prop_add(1, 1, #{type: 'test1', length: 1, id: -1})", 'E1293:') + + call prop_type_delete('test1') +endfunc + +func Test_error_after_using_negative_id() + " This needs to run a separate Vim instance because the + " "did_use_negative_pop_id" will be set. + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + + setline(1, ['one', 'two', 'three']) + prop_type_add('test_1', {highlight: 'Error'}) + prop_type_add('test_2', {highlight: 'WildMenu'}) + + prop_add(3, 1, { + type: 'test_1', + length: 5, + id: -1 + }) + + def g:AddTextprop() + prop_add(1, 0, { + type: 'test_2', + text: 'The quick fox', + text_padding_left: 2 + }) + enddef + END + call writefile(lines, 'XtextPropError', 'D') + let buf = RunVimInTerminal('-S XtextPropError', #{rows: 8, cols: 60}) + call VerifyScreenDump(buf, 'Test_prop_negative_error_1', {}) + + call term_sendkeys(buf, ":call AddTextprop()\<CR>") + call VerifyScreenDump(buf, 'Test_prop_negative_error_2', {}) + + call StopVimInTerminal(buf) +endfunc " vim: shiftwidth=2 sts=2 expandtab |