patch 8.2.1035: setreg() does not always clear the register

Problem:    setreg() does not always clear the register.
Solution:   Clear the register if the dict argument is empty. (Andy Massimino,
            closes #3370)
This commit is contained in:
Bram Moolenaar
2020-06-22 19:10:56 +02:00
parent 38041da1c2
commit 7633fe595e
3 changed files with 71 additions and 36 deletions

View File

@ -485,6 +485,14 @@ func Test_set_register_dict()
call assert_equal(['six'], getreginfo('0').regcontents)
call assert_equal(['six'], getreginfo('"').regcontents)
let @x = 'one'
call setreg('x', {})
call assert_equal(1, len(split(execute('reg x'), '\n')))
call assert_fails("call setreg('0', #{regtype: 'V'}, 'v')", 'E118:')
call assert_fails("call setreg('0', #{regtype: 'X'})", 'E475:')
call assert_fails("call setreg('0', #{regtype: 'vy'})", 'E475:')
bwipe!
endfunc