# HG changeset patch # User Bram Moolenaar # Date 1669674603 -3600 # Node ID 985a3d6e1d4b813ba44a33a384a0c860a948fc0b # Parent 8f50da4cfb18c457fc98f488ed2dd95178da3cbc patch 9.0.0969: matchparen highlight is not updated when switching buffers Commit: https://github.com/vim/vim/commit/28a896f54d4b2f2b4bef8ef4144dde1673c9d6e7 Author: Bram Moolenaar Date: Mon Nov 28 22:21:12 2022 +0000 patch 9.0.0969: matchparen highlight is not updated when switching buffers Problem: Matchparen highlight is not updated when switching buffers. Solution: Listen to the BufLeave and the BufWinEnter autocmd events. (closes #11626) diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar -" Last Change: 2021 Apr 08 +" Last Change: 2022 Nov 28 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -19,8 +19,8 @@ endif augroup matchparen " Replace all matchparen autocommands - autocmd! CursorMoved,CursorMovedI,WinEnter,WinScrolled * call s:Highlight_Matching_Pair() - autocmd! WinLeave * call s:Remove_Matches() + autocmd! CursorMoved,CursorMovedI,WinEnter,BufWinEnter,WinScrolled * call s:Highlight_Matching_Pair() + autocmd! WinLeave,BufLeave * call s:Remove_Matches() if exists('##TextChanged') autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair() endif diff --git a/src/testdir/dumps/Test_matchparen_clear_highlight_1.dump b/src/testdir/dumps/Test_matchparen_clear_highlight_1.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_matchparen_clear_highlight_1.dump @@ -0,0 +1,5 @@ +>(+0(ffff15|)| +0&#ffffff0@72 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|,|1| @10|A|l@1| diff --git a/src/testdir/dumps/Test_matchparen_clear_highlight_2.dump b/src/testdir/dumps/Test_matchparen_clear_highlight_2.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_matchparen_clear_highlight_2.dump @@ -0,0 +1,5 @@ +>a+0&#ffffff0@1| @72 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|,|1| @10|A|l@1| diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim --- a/src/testdir/test_display.vim +++ b/src/testdir/test_display.vim @@ -237,6 +237,37 @@ func Test_visual_block_scroll() call StopVimInTerminal(buf) endfunc +" Test for clearing paren highlight when switching buffers +func Test_matchparen_clear_highlight() + CheckScreendump + + let lines =<< trim END + source $VIMRUNTIME/plugin/matchparen.vim + set hidden + call setline(1, ['()']) + normal 0 + + func OtherBuffer() + enew + exe "normal iaa\0" + endfunc + END + call writefile(lines, 'XMatchparenClear', 'D') + let buf = RunVimInTerminal('-S XMatchparenClear', #{rows: 5}) + call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {}) + + call term_sendkeys(buf, ":call OtherBuffer()\:\") + call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {}) + + call term_sendkeys(buf, "\:\") + call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {}) + + call term_sendkeys(buf, "\:\") + call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {}) + + call StopVimInTerminal(buf) +endfunc + func Test_display_scroll_at_topline() CheckScreendump diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 969, +/**/ 968, /**/ 967,