Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring a session if winheight > lines, a "Not enough room" error is thrown #2970

Closed
darrellnash opened this issue May 30, 2018 · 2 comments

Comments

@darrellnash
Copy link

darrellnash commented May 30, 2018

If a user has a winheight set higher than a window's &lines value, when saving a session and restoring it later, a "E36: Not enough room" error is thrown, causing the rest of the session settings to fail to load.

To Reproduce (Vim v8.1.26):

Set winheight large, and save a session:

vim -N -u NONE --cmd 'set winheight=999' --cmd 'mksession! /tmp/session.vim'

Exit, and then an error is thrown when restoring the session:

vim -N -u NONE --cmd 'source /tmp/session.vim'

Expected Behavior:

A user should be able to restore a session without an error being thrown, no matter what winheight is set to.

--

Here is a simplified repro case, without needing a session:

vim -N -u NONE --cmd 'set winheight=999' --cmd 'set winminheight=1 winheight=1 winminwidth=1 winwidth=1'

Edit: The below is wrong - there's more to this than I initially thought, though I'm not following the code too well in src/window.c, which is what throws the error. There is still a bug, however.

The problem appears to be from line 11277 of src/ex_docmd.c, which has the following settings hardcoded when saving a session:

if (put_line(fd, "set winminheight=1 winheight=1 winminwidth=1 winwidth=1") == FAIL)

It appears that line just temporarily sets those settings while it opens the buffers, but then restores the user's initial settings. I'm not 100% sure if this is the correct fix, but I have verified that changing the min values to 0 gets rid of the error:

vim -N -u NONE --cmd 'set winheight=999' --cmd 'set winminheight=0 winheight=1 winminwidth=0 winwidth=1'

As an aside, the reason I've set winheight=999 in the first place is due to how I use vertical splits. It's nice to have the split auto-expand to the full height while navigating around them, as detailed in this vim tip.

(edit: pulled my simple fix, as it doesn't actually fix the underlying issue).

@tonymec
Copy link

tonymec commented May 30, 2018

Indeed, the hard minimum is 'winminheight', not 'winheight', with the proviso that the current window always gets at least one line in adition to its statusline, even if 'winminheight' is zero.
Myself, I set 'winminheight' to zero and 'winheight' to 9999 as part of what I call "Rolodex Vim", where the current window expands to the maximum possible height, reducing all other windows to only a statusline above and below it, as in an office Rolodex where the current index card is open full-height while all others are reduced to tabs above and below it.

Best regards,
Tony.

@darrellnash
Copy link
Author

Nice! That's exactly how I've operated for years (minus the fancy toggles in your link). Clever name for it.

I only noticed and reported this problem because I finally got around to playing with mksession, but I sadly can't use them without some workaround until this bug is fix.

janlazo added a commit to janlazo/neovim that referenced this issue Sep 2, 2019
Problem:    Loading a session file fails if 'winheight' is a big number.
Solution:   Set 'minwinheight' to zero at first.  Don't give an error when
            setting 'minwinheight' while 'winheight' is a big number.
            Fix using vertical splits. Fix setting 'minwinwidth'.
            (closes vim/vim#2970)
vim/vim@1c3c104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants