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

Window contents shift when toggling horizontal terminals #417

Open
brdoney opened this issue Mar 22, 2023 · 5 comments
Open

Window contents shift when toggling horizontal terminals #417

brdoney opened this issue Mar 22, 2023 · 5 comments

Comments

@brdoney
Copy link

brdoney commented Mar 22, 2023

I migrated over to this plugin from vim-terminal-help because I love switching terminals from the horizontal to floating directions on the fly. However, one difference that I noticed is that when I open/close a horizontal terminal, the contents of splits are shifted accordingly. I find this a bit distracting.

To give some more concrete information, the way that vim-terminal-help gets around this is by calling windo winsaveview and windo winrestview before and after the terminal opens/closes, respectively. That way, any shifts from opening or closing the terminal split are undone after they occur.

This seems like a simple change, so I would be happy to implement it if the shifting isn't intentional! I do wonder if the change would also make sense for the vertical layout too.

@akinsho
Copy link
Owner

akinsho commented Mar 23, 2023

Hi @brdoney thanks for recommending this, I think some time ago in the earliest days of this plugin when it was a vimscript file in my dotfiles I did have something like this in place but there wasn't a lua equivalent so it got dropped. I'm definitely open to having this added if it does indeed work as intended. Would be good to have some sort of before and after imagery/gif.

I think it's also worth noting that splitkeep now exists and seeing whether that is something that can also help here?

@brdoney
Copy link
Author

brdoney commented Mar 24, 2023

I forgot about splitkeep! In particular, the topline option is pretty close to what I was looking for, but with one notable difference: it moves the cursor if it goes out of bounds. This means that one-off actions like opening a horizontal terminal, running a command, then closing the terminal have the potential to change your cursor position in all open windows, which doesn't seem ideal.

winsave/restview don't shift the cursor if it goes out of bounds, the cursor just won't be visible until you change into the split (upon which case the viewport will shift down to where it is), so there's no chance of cursor positions shifting at all in the one-off action example.

I'll give a quick implementation a shot this weekend and post some gifs of the current behaviour, the splitkeep=topline behaviour, and the behaviour with winsave/restview.

@akashdiphazra
Copy link

Problem description

Terminal text shifts or disappears after opening the file explorer.

Screencast from 2023-02-28 21-00-54

@akinsho
Copy link
Owner

akinsho commented Jun 2, 2023

@brdoney if your issue is the same as the OP's i.e. specific to horizontal windows then please have a look at the splitkeep setting as discussed. If your issue is that the file explorer buffer reduces the size of the terminal window i.e. relates to vertical windows then it joins the dozens of previous issues and comments on the issue I've had in the past and gets the same response which is that this is how neovim works.

The file explorer is not special it doesn't get any special treatment and this is how neovim behaves when a window is split vertically. I don't know a way that doesn't involve a multitude of hacks to resolve this. If you or anyone else has a solution please feel free to PR 🙏🏾 otherwise we will all just have to live with it.

@ColinKennedy
Copy link

To anyone reading, the "text gets chopped off after resizing" issue - I think with Neovim nightly this was fixed. See "neovim reflow", this pull request - neovim/neovim#21124

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

4 participants