From b8ecfc3cbb8dd6bf1fab51c4641ba779dc2ba621 Mon Sep 17 00:00:00 2001 From: Ben Motz Date: Thu, 23 Jul 2026 21:42:14 +0100 Subject: [PATCH] Only refresh flags when switching to normal buffers This resolves a bug when using Telescope with NerdTree and this plugin, where input focus ends up in the wrong part of the Telescope window. What happens at present 1. Telescope is opened, creating several windows 2. The first of these is created, causing BufEnter to fire, running the autocmd in this plugin 3. The plugin records the window number of the buffer 4. Switches to the NerdTree window (to refresh the flags) 5. Telescope creates some more windows, which invalidates the window number that the plugin recorded 6. When the plugin restores focus, it restores it to the wrong window, and the input focus in Telescope ends up in the wrong place. Fix by only calling RefreshFlags() for normal editable buffers, where buftype = '' --- nerdtree_plugin/highlight_open_buffers.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nerdtree_plugin/highlight_open_buffers.vim b/nerdtree_plugin/highlight_open_buffers.vim index a3fb55d..d7601c1 100644 --- a/nerdtree_plugin/highlight_open_buffers.vim +++ b/nerdtree_plugin/highlight_open_buffers.vim @@ -24,7 +24,8 @@ endfunction " Autocmds to trigger NERDTree flag refreshes augroup NERDTreeHighlightOpenBuffersPlugin - autocmd CursorHold,BufEnter * silent! call s:RefreshFlags() + autocmd CursorHold * silent! call s:RefreshFlags() + autocmd BufEnter * if &buftype ==# '' | silent! call s:RefreshFlags() | endif autocmd BufWritePost,BufReadPost * silent! s:RefreshFlags() augroup END function! s:RefreshFlags()