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

:terminal text clipped after resize #4997

Open
khughitt opened this issue Jul 1, 2016 · 28 comments
Open

:terminal text clipped after resize #4997

khughitt opened this issue Jul 1, 2016 · 28 comments
Assignees
Labels
bug issues reporting wrong behavior terminal built-in :terminal or :shell
Milestone

Comments

@khughitt
Copy link

khughitt commented Jul 1, 2016

  • nvim --version: NVIM v0.1.5-508-g47a15d0
  • Vim (version: ) behaves differently? N/A
  • Operating system/version: Arch Linux (64-bit Linux 4.6.3-1)
  • Terminal name/version: rxvt-unicode v9.22
  • $TERM: rxvt-256color

Actual behaviour

Text in Neovim terminal becomes clipped on the right side after reducing window size to a width smaller than what is displayed.

Expected behaviour

Terminal text return to its original unclipped after the window is temporarily narrowed.

Steps to reproduce using nvim -u NORC

  1. nvim -u NORC
  2. Open a terminal using :term and then print some long line to the screen. Initially the entire text will be displayed:
$ echo "abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy"                                               
abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy 

If the screen is then resized (e.g. 50% width), and then resized back to 100% width, the text is now clipped at the position where it was hidden when the terminal size was reduced:

$ echo "abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn op                                                                                       
abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy abcdefg hijklmn opqrstuv xzy 

(Thanks @jalvesaq for coming up with this simple example to reproduce the issue).

@justinmk
Copy link
Member

justinmk commented Jul 1, 2016

This is because of #4929 (comment).

As I mentioned there, instead of forcing the resize at every BufEnter/WinEnter, I think instead the terminal resize should only happen on :redraw! / <C-L> .

Those who want to force it unconditionally can set up a handler:

au TermOpen * au <buffer> BufEnter,WinEnter redraw!

But in most cases I think the terminal size should never be reduced, because it loses data. At least until (if ever) libvterm gains the ability to remember off-screen text.

edit: @leonerd mentioned in gitter that this is currently the expected libvterm behavior.

@justinmk justinmk added bug issues reporting wrong behavior terminal built-in :terminal or :shell labels Jul 1, 2016
@justinmk justinmk added this to the 0.2 milestone Jul 1, 2016
@khughitt
Copy link
Author

khughitt commented Jul 1, 2016

That makes sense. I agree with your suggestions about the default redraw behavior.

Thanks for the explanation!

@mhinz

This comment has been minimized.

@justinmk

This comment has been minimized.

@justinmk
Copy link
Member

justinmk commented Jul 1, 2016

@mhinz Also I think totally reverting #4929 is not necessary. Perhaps it could be modified to resize only if the target size is greater than the previous size. That way #4820 and #3864 won't regress.

@mhinz
Copy link
Member

mhinz commented Jul 9, 2016

But then it would be possible that you don't even see the prompt if you switch back to a smaller window with the same terminal.

Basically we only have these options:

  • old way: Resize the terminal to the smallest embedding window which renders excess space in bigger windows unusable.
  • new way: Make the terminal dimensions fit into the current window. Problem: If you came from a smaller window, text will be lost due to the also smaller terminal text buffer.

In hindsight, I'd vote for the old way (so a full merge revert), but making :redraw!/<c-l> fitting a potential terminal into the current window + making terminal_resize() aware of the {number,sign,fold} column.

@justinmk justinmk modified the milestones: 0.3, 0.2 Oct 31, 2016
@justinmk justinmk modified the milestones: 0.2, 0.3, 0.2.1 Mar 14, 2017
@justinmk justinmk modified the milestones: 0.2.1, 0.2.2 Sep 16, 2017
@justinmk justinmk changed the title terminal text clipped after resizing window terminal text clipped after resize Oct 17, 2017
justinmk added a commit to justinmk/neovim that referenced this issue Nov 13, 2017
closes neovim#7538
Fix wrong window references from neovim#5310

Remove some eager resizing. Still mostly doesn't address neovim#4997.
justinmk added a commit to justinmk/neovim that referenced this issue Nov 13, 2017
closes neovim#7538
Fix wrong window references from neovim#7440

Remove some eager resizing. Still mostly doesn't address neovim#4997.
justinmk added a commit that referenced this issue Nov 13, 2017
closes #7538
Fix wrong window references from #7440

Remove some eager resizing. Still mostly doesn't address #4997.
@GCorbel

This comment has been minimized.

@sprice-janrain
Copy link

I still experience this with v0.3.0-1233-gde7a0bdc3. Vim 8.1 was released today, and I noticed that it also has :terminal now. It works a bit differently, but I did see that scrollback text is not clipped when you resize windows. It's also using a customized libvterm, right? what's different here?

@justinmk
Copy link
Member

justinmk commented May 19, 2018

@sprice-janrain It does clip text, I just tried in vim8.1:

:term
ls
ctrl-w N
ctrl-w v
i

@sprice-janrain
Copy link

Ok, to clarify, i do see clipping, but if I switch back to that original terminal and then switch to Normal mode with ctrl-w ctrl-n, I see the text restored.

@justinmk

This comment has been minimized.

@tbo

This comment has been minimized.

@justinmk

This comment has been minimized.

@skt041959

This comment has been minimized.

@justinmk
Copy link
Member

related: #2514

@janlazo janlazo modified the milestones: 0.5, 0.5.1 Feb 14, 2021
@bfredl bfredl modified the milestones: 0.5.1, 0.6 Aug 15, 2021
@tipa40

This comment has been minimized.

@Shougo
Copy link
Contributor

Shougo commented Oct 17, 2021

Hi. I have tested it and :redraw! does not fix the problem unfortunately.

@clason
Copy link
Member

clason commented Nov 19, 2022

You can try building from master with reflow enabled: #20222 (comment)

Testing this feature and reporting on any issues with it (or lack thereof) will help with this.

@bfredl bfredl modified the milestones: 0.9, 0.10 Apr 7, 2023
@nyngwang
Copy link

nyngwang commented May 1, 2023

@clason Not sure if it's appropriate to ask you here: Is that "inserting a line into the neovim/src/nvim/terminal.c" the only way to apply the patch or do we have some flag(?) to do this? Anyway, always appreciate your (huge!) contributions to Neovim :)

@clason
Copy link
Member

clason commented May 1, 2023

Yes, that's the only way (or check out the linked PR).

@nyngwang
Copy link

nyngwang commented May 1, 2023

Can I call this a success? NVIM v0.10.0-dev-241+g26cc94622-dirty:

note: but if I resize it "too much", the problem of OP seems to still persist (lines got truncated).

Screen.Recording.2023-05-02.at.1.18.57.AM.mov

@clason
Copy link
Member

clason commented May 1, 2023

Yes, as explained in the PR, the scrollback buffer does not reflow.

@nyngwang
Copy link

nyngwang commented May 1, 2023

I just tried stretching the output of cat src/nvim/terminal.c and it works perfectly (I resized it such that the terminal-buffer split disappeared entirely, and all contents got recovered after I stretched it back to the original width). I hope this quick test might help a little bit. Thanks for your help!

@neovim neovim deleted a comment from OwariDa Nov 27, 2023
@neovim neovim deleted a comment from Shougo Nov 27, 2023
@neovim neovim deleted a comment from satishskamath Nov 27, 2023
@dundargoc dundargoc modified the milestones: 0.10, backlog Mar 30, 2024
@justinmk justinmk changed the title terminal text clipped after resize :terminal text clipped after resize Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior terminal built-in :terminal or :shell
Projects
None yet
Development

No branches or pull requests