]> gitweb.fluxo.info Git - rhatto/dotfiles/vim.git/commitdiff
Fix: run FixAllNERDTreeWidths() only once
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 28 Jul 2024 13:30:49 +0000 (10:30 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 28 Jul 2024 13:30:49 +0000 (10:30 -0300)
vim.dot.link/filetype.vim
vim.dot.link/plugin/nerdtree_workarounds.vim

index 6679641db88f92699c27133d6bc878512297b9f7..9204987ad4205cd279ff293d59c25a38abf241d0 100644 (file)
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 
 if exists("did_load_filetypes")
- finish
 finish
 endif
 
 " Markdown
index d0d682e9fc191d5f9e963f72af2b41c1bb25ab81..a78ed0c38ca7918723157f06ff2e1ee9be564c59 100644 (file)
@@ -32,6 +32,11 @@ command! -bang FixNERDTreeWidth :call FixNERDTreeWidth()
 
 " Fix NERDTree width on all tabs
 function FixAllNERDTreeWidths()
+  " Make sure to run this only once
+  if exists("did_fixed_nerdtree_widths")
+    return
+  endif
+
   " Save the last active window
   let l:current_win = win_getid()
 
@@ -42,14 +47,17 @@ function FixAllNERDTreeWidths()
 
   " An additional, last move to the left pane
   wincmd l
+
+  let dir_fixed_nerdtree_widths=1
 endfunction
 
 " Fix all NERDTree widths afert session load
 augroup workaround
   autocmd!
-  " This tends to fire for every buffers
-  "autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths()
+  " This tends to fire for every buffer
+  autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths()
 
-  " This seems to fire only once
-  autocmd workaround VimEnter * call FixAllNERDTreeWidths()
+  " This seems to fire only once, but even when there's no session to be
+  " restored.
+  "autocmd workaround VimEnter * call FixAllNERDTreeWidths()
 augroup END