zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

Error "E444: Cannot close last window." when trying to close last window. #9

Closed jordwalke closed 7 years ago

jordwalke commented 7 years ago

When I try to close the last window using :WintabsClose, I get the mentioned error. I would like it to close vim entirely when I run :WintabsClose on the final window/buffer.

No configuration of |g:wintabs_autoclose| or *g:wintabs_autoclose_vimtab* make this work.

I am testing in MacVim.

zefei commented 7 years ago

I'll fix this.

Meanwhile I'd really suggest close vim using vim commands (:quit, ZZ, ZQ) as they work very well with session and vimtabs (you can restore last session with all vimtab buffers re-opened).

jordwalke commented 7 years ago

@zefei As a user, I just want to be able to hit my keyboard shortcut for "close the thing", and have it close my buffers (wintabs actually) one by one, and then when I've finally closed all of them, that same command should close out of the final window, which quits Vim. This is how most applications that I use function (such as Chrome for example).

Wintabs works well in this way for closing the window/tab when you've closed all the buffers inside of it - I just think that same consistency should extend to the final window, and therefore the entire app.

jordwalke commented 7 years ago

Bountysource

jordwalke commented 7 years ago

@zefei Do you know of any way to do everything just as wintabs currently does it, but then have it automatically use :q for the final close? Is there a way to programmatically check how many wintabs remain assigned to the current window? I can create a custom key mapping that checks if I am the last window open, and then if I am also the last wintabs buffer assigned to this window, I would then have the keymapping call :q instead of WinTabsClose. I do feel like this should be the default behavior, but I'm definitely willing to create my own mapping that does it, if you are aware of a way to do this.

zefei commented 7 years ago

@jordwalke I didn't have much time last week, I'll probably fix it this weekend as this is just a one line fix. If you really want to do it now, you can do

noremap <KEY> :<C-U>call <SID>close_wintab()<CR>
function! s:close_wintab()
  try | WintabsClose | catch | quit | endtry
endfunction
jordwalke commented 7 years ago

Thanks for the suggestion.

screen shot 2017-01-27 at 11 06 30 pm

It seems this results in an error.

jordwalke commented 7 years ago

This function parses correctly:

function! s:close_wintab()
  try
    WintabsClose 
  catch
    quit
  endtry
endfunction

Thank you!

zefei commented 7 years ago

I added option g:wintabs_autoclose_vim, closing this.

jordwalke commented 7 years ago

Thanks so much!