vim-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 vim/vim#3370)
7633fe595e

Do not getdigits for block_len strictly. For example, a user could
previously abort Nvim using:

:call setreg("0", "abort!", "\<C-V>999999999999999999")

or, after v8.2.0924's port:

:call setreg("0", #{regcontents: ["abort!"],
                  \ regtype: "\<C-V>999999999999999999"})

Instead, default to 0 so block_len is -1, which acts like the selection
width was omitted (defaults to length of longest line).
This commit is contained in:
Sean Dewar
2021-09-22 14:59:08 +01:00
parent f8241f825a
commit f1bf70c2f9
2 changed files with 58 additions and 32 deletions

View File

@@ -352,6 +352,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