junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.49k stars 115 forks source link

resize_pads exits early if no padding has been initialized #187

Open haberdashPI opened 5 years ago

haberdashPI commented 5 years ago

Hi there, this is a simple, somewhat hacky fix for a problem I ran into when initializing Goyo.

The problem I was running into was that I had an autocmd in my .vimrc to resize the windows to be evenly split on a WinEnter event. This lead to problems that I don't quite understand where resize_pads was called within init_pads; I don't understand it because it looks like Goyo doesn't add the autocmd for resize_pads until after init_pads, but somehow this got called anyways even on a fresh start of vim.

My fix to this was just to add a flag to verify that all init_pad calls have been run; if they haven't been, resize_pad returns without resizing.

If you want to make a less hacky fix than the one I have here, I ran into this problem on neovim 0.3.1. The window resizing I am doing is somewhat indirect so that may also matter: I call a command from another plugin that happens to resize the windows in a specific way (<Plug>(repl-resize) in https://github.com/haberdashPI/vim-multi-repl).