patch 9.1.1419: It is difficult to ignore all but some events
Problem: It is difficult to ignore all but some events.
Solution: Add support for a "-" prefix syntax in '(win)eventignore' that
subtracts an event from the ignored set if present
(Luuk van Baal).
closes: #17392
Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim
index 1f15453..5b9616f 100644
--- a/src/testdir/gen_opt_test.vim
+++ b/src/testdir/gen_opt_test.vim
@@ -195,9 +195,9 @@
\ ['xxx']],
\ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
\ 'encoding': [['latin1'], ['xxx', '']],
- \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
+ \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'],
\ ['xxx']],
- \ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
+ \ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'],
\ ['xxx', 'WinNew']],
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
\ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index dfeb93f..3dc4960 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -5463,4 +5463,20 @@
%bw!
endfunc
+func Test_eventignore_subtract()
+ set eventignore=all,-WinEnter
+ augroup testing
+ autocmd!
+ autocmd WinEnter * ++once let s:triggered = 1
+ augroup END
+
+ new
+ call assert_equal(1, s:triggered)
+
+ set eventignore&
+ unlet! s:triggered
+ call CleanUpTestAuGroup()
+ %bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 8679198..e85dd6a 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -602,6 +602,7 @@
" Other string options that queries the system rather than fixed enum names
call assert_equal(['all', 'BufAdd'], getcompletion('set eventignore=', 'cmdline')[0:1])
+ call assert_equal(['-BufAdd', '-BufCreate'], getcompletion('set eventignore=all,-', 'cmdline')[0:1])
call assert_equal(['WinLeave', 'WinResized', 'WinScrolled'], getcompletion('set eiw=', 'cmdline')[-3:-1])
call assert_equal('latin1', getcompletion('set fileencodings=', 'cmdline')[1])
call assert_equal('top', getcompletion('set printoptions=', 'cmdline')[0])