1
0
forked from aniani/vim

patch 8.2.5011: Replacing an autocommand requires several lines

Problem:    Replacing an autocommand requires several lines.
Solution:   Add the "replace" flag to autocmd_add(). (Yegappan Lakshmanan,
            closes #10473)
This commit is contained in:
Yegappan Lakshmanan
2022-05-24 11:40:11 +01:00
committed by Bram Moolenaar
parent c9a431c763
commit 971f6825ee
5 changed files with 58 additions and 11 deletions

View File

@@ -3413,6 +3413,18 @@ func Test_autocmd_add()
\ nested: v:false, once: v:false, event: 'BufHidden'}],
\ autocmd_get(#{group: 'TestAcSet'}))
" Test for replacing a cmd for an event in a group
call autocmd_delete([#{group: 'TestAcSet'}])
call autocmd_add([#{replace: v:true, group: 'TestAcSet', event: 'BufEnter',
\ pattern: '*.py', cmd: 'echo "bufenter"'}])
call autocmd_add([#{replace: v:true, group: 'TestAcSet', event: 'BufEnter',
\ pattern: '*.py', cmd: 'echo "bufenter"'}])
call assert_equal([
\ #{cmd: 'echo "bufenter"', group: 'TestAcSet', pattern: '*.py',
\ nested: v:false, once: v:false, event: 'BufEnter'}],
\ autocmd_get(#{group: 'TestAcSet'}))
" Test for adding a command for an unsupported autocmd event
let l = [#{group: 'TestAcSet', event: 'abc', pattern: '*.sh',
\ cmd: 'echo "bufadd"'}]
call assert_fails('call autocmd_add(l)', 'E216:')