Xuyuanp / nerdtree-git-plugin

A plugin of NERDTree showing git status
Do What The F*ck You Want To Public License
2.08k stars 150 forks source link

Avoid triggering unnecessary autocmds when moving cursor #173

Closed airblade closed 3 years ago

airblade commented 3 years ago

Description

diff --git i/autoload/gitstatus/listener.vim w/autoload/gitstatus/listener.vim
index 13e9d1e..41b266a 100644
--- i/autoload/gitstatus/listener.vim
+++ w/autoload/gitstatus/listener.vim
@@ -97,8 +97,8 @@ function! s:Listener.TryUpdateNERDTreeUI() abort
         call b:NERDTree.root.refreshFlags()
         call NERDTreeRender()
     finally
-        exec l:altwinnr . 'wincmd w'
-        exec l:winnr . 'wincmd w'
+        noautocmd exec l:altwinnr . 'wincmd w'
+        noautocmd exec l:winnr . 'wincmd w'
     endtry
 endfunction

Currently when the cursor makes those two window jumps, it triggers BufEnter autocmds. Presumably we do not want to do that.

I noticed this while investigating an issue with the autocmds triggered by these BufEnter events.

Xuyuanp commented 3 years ago

Thanks, could you open a PR?

airblade commented 3 years ago

Please see #174.

Xuyuanp commented 3 years ago

Merged. Thanks for your contribution.