]> granicus.if.org Git - vim/commitdiff
patch 9.0.0969: matchparen highlight is not updated when switching buffers v9.0.0969
authorBram Moolenaar <Bram@vim.org>
Mon, 28 Nov 2022 22:21:12 +0000 (22:21 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 28 Nov 2022 22:21:12 +0000 (22:21 +0000)
Problem:    Matchparen highlight is not updated when switching buffers.
Solution:   Listen to the BufLeave and the BufWinEnter autocmd events.
            (closes #11626)

runtime/plugin/matchparen.vim
src/testdir/dumps/Test_matchparen_clear_highlight_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_matchparen_clear_highlight_2.dump [new file with mode: 0644]
src/testdir/test_display.vim
src/version.c

index ce2225c5f860c45826ffd2c8fce47ab439776e1c..eb4a9ecf7cdeb9f2484f371bedcf83655caafce4 100644 (file)
@@ -1,6 +1,6 @@
 " Vim plugin for showing matching parens
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" 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 (file)
index 0000000..1a96275
--- /dev/null
@@ -0,0 +1,5 @@
+>(+0&#40ffff15|)| +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 (file)
index 0000000..c3f93fa
--- /dev/null
@@ -0,0 +1,5 @@
+>a+0&#ffffff0@1| @72
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index 4364f03fb20cf4cae8e96cc57c6ca139f0b8caf2..abf1cd0cd0b20868be7f6c53420dc58fcfe80e9b 100644 (file)
@@ -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\<Esc>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()\<CR>:\<Esc>")
+  call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {})
+
+  call term_sendkeys(buf, "\<C-^>:\<Esc>")
+  call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {})
+
+  call term_sendkeys(buf, "\<C-^>:\<Esc>")
+  call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_display_scroll_at_topline()
   CheckScreendump
 
index f26f91a44a40f85eabbb705a6f868617b9b8556f..78df0d8c6d29d9f705ead06398ba73882aa2ceea 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    969,
 /**/
     968,
 /**/