Skip to content

bugfix: Stop executing t:CtrlSpaceWinrestcmd#306

Merged
Konfekt merged 2 commits intovim-ctrlspace:masterfrom
Minion3665:bugfix/271/do-not-execute-CtrlSpaceWinrestcmd
Oct 30, 2022
Merged

bugfix: Stop executing t:CtrlSpaceWinrestcmd#306
Konfekt merged 2 commits intovim-ctrlspace:masterfrom
Minion3665:bugfix/271/do-not-execute-CtrlSpaceWinrestcmd

Conversation

@Minion3665
Copy link
Contributor

- Previously this caused an interaction with other plugins where if they
  opened other windows this would cause ctrlspace to shrink windows to
  the minimum size
- (From :help winrestcmd()) "Only works properly when no windows are
  opened or closed and the current window and tab page is unchanged"
- From testing in
  vim-ctrlspace#271 it seems
  that this line is not required, so this commit removes it
- This commit will
  close vim-ctrlspace#271
@Minion3665
Copy link
Contributor Author

@Konfekt here's the PR I was talking about; I've tested it on my system a little and everything seems to be going fine, but obviously review the code as well before merging (it's very small)

@Konfekt
Copy link
Collaborator

Konfekt commented Oct 30, 2022

Thank you! There are other occurrences of

silent! exe t:CtrlSpaceWinrestcmd

and accompanying commands to set t:CtrlSpaceWinrestcmd peppered out all over the place.
These work fine though?
Do you have a hunch why that does not interfere with the window layout?

Also, how about making the removed code instead conditional on Nvim as long as no Vim users chime in.

@Minion3665
Copy link
Contributor Author

Thank you! There are other occurrences of

silent! exe t:CtrlSpaceWinrestcmd

and accompanying commands to set t:CtrlSpaceWinrestcmd peppered out all over the place. These work fine though? Do you have a hunch why that does not interfere with the window layout?

Are you sure? A quick grep of the codebase doesn't get me anything else that actually executes t:CtrlSpaceWinrestcmd

image

The reason I didn't remove t:CtrlSpaceWinrestcmd altogether is that it is used to unset wincmd in the ctrlspace#window#GoToStartWindow function and I wanted to make as small of a codebase modification as possible

Also, how about making the removed code instead conditional on Nvim as long as no Vim users chime in.

If you like; the reason I'm a little cautious in doing that is that the help section we're using to justify this change is also present in vim
image

@Konfekt
Copy link
Collaborator

Konfekt commented Oct 30, 2022

Are you sure? A quick grep of the codebase doesn't get me anything else that actually executes t:CtrlSpaceWinrestcmd

True, my fault.

So instead of restoring the faulty windows layout by

       silent! exe t:CtrlSpaceWinrestcmd

now all windows are made equal by

        wincmd =

How about adding case distinction with a comment on :help winrestcmd(), opting for the latter in Nvim and the former in Vim? Trying to restore the layout seems the first option, the second one rather brute.

I'd then wait for Vim users complaining about the same issue to enact the current code change.

- As Neovim users are the users who seem to be facing the issue with
  t:CtrlSpaceWinrestcmd, it seems like a good idea to still resize the
  windows back for vim users
- Notwithstanding the help message that winrestcmd() "Only works
  properly when no windows are opened or closed and the current window
  and tab page is unchanged" in vim, as no vim users have come forward
  saying they have an issue we believe there to be none
@Konfekt Konfekt merged commit 5e444c6 into vim-ctrlspace:master Oct 30, 2022
@Konfekt
Copy link
Collaborator

Konfekt commented Oct 30, 2022

Thank you!

@Minion3665 Minion3665 deleted the bugfix/271/do-not-execute-CtrlSpaceWinrestcmd branch October 30, 2022 13:48
gibfahn added a commit to gibfahn/vim-peekaboo that referenced this pull request Jun 17, 2024
If you look at `:h winrestcmd` it says:

```
winrestcmd()                                                      *winrestcmd()*
  Returns a sequence of |:resize| commands that should restore
  the current window sizes.  Only works properly when no windows
  are opened or closed and the current window and tab page is
  unchanged.
  Example: >vim
    let cmd = winrestcmd()
    call MessWithWindowSizes()
    exe cmd
```

We can't guarantee this, so don't try to restore windows.

Refs: neoclide/coc.nvim#4178 (comment)
Refs: vim-ctrlspace/vim-ctrlspace#306
Fixes: junegunn#74
Fixes: junegunn#83
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

Successfully merging this pull request may close these issues.

Sometimes the current layout window shrinks to max when triggering the buffer list.

2 participants

Comments