Skip to content

Commit 49ffb6b

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.0167: Changing buffer in another window causes it to show matchparen
Problem: Changing buffer in another window using win_execute() causes it to show matchparen (after 9.0.0969). Solution: Delay highlighting with SafeState in BufWinEnter. (zeertzjq) closes: #14177 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 5406eb8 commit 49ffb6b

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

runtime/plugin/matchparen.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ let s:has_matchaddpos = exists('*matchaddpos')
2222

2323
augroup matchparen
2424
" Replace all matchparen autocommands
25-
autocmd! CursorMoved,CursorMovedI,WinEnter,BufWinEnter,WinScrolled * call s:Highlight_Matching_Pair()
25+
autocmd! CursorMoved,CursorMovedI,WinEnter,WinScrolled * call s:Highlight_Matching_Pair()
26+
autocmd! BufWinEnter * autocmd SafeState * ++once call s:Highlight_Matching_Pair()
2627
autocmd! WinLeave,BufLeave * call s:Remove_Matches()
2728
if exists('##TextChanged')
2829
autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
>{+0&#40ffff15|}| +0&#ffffff0@72
2+
|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1
3+
|{+0&&|}| @72
4+
|[+1&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1
5+
| +0&&@74

src/testdir/test_matchparen.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,31 @@ func Test_matchparen_clear_highlight()
6161
call StopVimInTerminal(buf)
6262
endfunc
6363

64+
" Test for matchparen highlight when switching buffer in win_execute()
65+
func Test_matchparen_win_execute()
66+
CheckScreendump
67+
68+
let lines =<< trim END
69+
source $VIMRUNTIME/plugin/matchparen.vim
70+
let s:win = win_getid()
71+
call setline(1, '{}')
72+
split
73+
74+
func SwitchBuf()
75+
call win_execute(s:win, 'enew | buffer #')
76+
endfunc
77+
END
78+
call writefile(lines, 'XMatchparenWinExecute', 'D')
79+
let buf = RunVimInTerminal('-S XMatchparenWinExecute', #{rows: 5})
80+
call VerifyScreenDump(buf, 'Test_matchparen_win_execute_1', {})
81+
82+
" Switching buffer away and back shouldn't change matchparen highlight.
83+
call term_sendkeys(buf, ":call SwitchBuf()\<CR>:\<Esc>")
84+
call VerifyScreenDump(buf, 'Test_matchparen_win_execute_1', {})
85+
86+
call StopVimInTerminal(buf)
87+
endfunc
88+
6489
" Test for scrolling that modifies buffer during visual block
6590
func Test_matchparen_pum_clear()
6691
CheckScreendump

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
167,
707709
/**/
708710
166,
709711
/**/

0 commit comments

Comments
 (0)