File tree Expand file tree Collapse file tree 2 files changed +25
-13
lines changed
autoload/fern/internal/drawer Expand file tree Collapse file tree 2 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -5,22 +5,35 @@ function! fern#internal#drawer#auto_resize#init() abort
55
66 augroup fern_internal_drawer_init
77 autocmd ! * <buffer>
8- autocmd BufEnter <buffer> call s: resize ()
9- autocmd BufLeave <buffer> call s: resize ()
8+ autocmd BufEnter <buffer> call s: load_width ()
9+ autocmd BufLeave <buffer> call s: save_width ()
1010 augroup END
1111endfunction
1212
1313if has (' nvim' )
14- function ! s: is_relative () abort
14+ function ! s: should_ignore () abort
1515 return nvim_win_get_config (win_getid ()).relative !=# ' '
1616 endfunction
17-
18- function ! s: resize () abort
19- if s: is_relative ()
20- return
21- endif
22- call fern#internal#drawer#resize ()
23- endfunction
2417else
25- let s: resize = funcref (' fern#internal#drawer#resize' )
18+ function ! s: should_ignore () abort
19+ return 0
20+ endfunction
2621endif
22+
23+ function ! s: save_width () abort
24+ if s: should_ignore ()
25+ return
26+ endif
27+ let t :fern_drawer_auto_resize_width = winwidth (0 )
28+ endfunction
29+
30+ function ! s: load_width () abort
31+ if s: should_ignore ()
32+ return
33+ endif
34+ if ! exists (' t:fern_drawer_auto_resize_width' )
35+ call fern#internal#drawer#resize ()
36+ else
37+ execute ' vertical resize' t :fern_drawer_auto_resize_width
38+ endif
39+ endfunction
Original file line number Diff line number Diff line change @@ -422,8 +422,7 @@ VARIABLE *fern-variable*
422422 Default: 0
423423
424424*g:fern#disable_drawer_auto_resize*
425- Set 1 to disable automatically resize drawer on | BufEnter | and
426- | BufLeave | autocmd.
425+ Set 1 to disable automatically resize drawer on | BufEnter | autocmd.
427426
428427 Note that this feature is automatically disabled on floating windows
429428 of Neovim to avoid unwilling resize reported as #294
You can’t perform that action at this time.
0 commit comments