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

Output gets cut off towards the bottom #7

Closed
musjj opened this issue Sep 18, 2023 · 15 comments
Closed

Output gets cut off towards the bottom #7

musjj opened this issue Sep 18, 2023 · 15 comments
Labels

Comments

@musjj
Copy link

musjj commented Sep 18, 2023

With a huge scrollback, (try running ls -R on a big directory), this scrollback displayed by this plugin will get cut off towards the bottom. I noticed the same issue happening with homebrew kitty pager scripts I've found in the wild.

@mikesmithgh
Copy link
Owner

Thanks for the feedback.

  • Are you on Linux or Mac?
  • Could you provide a screenshot?

@musjj
Copy link
Author

musjj commented Sep 18, 2023

I'm on Linux.

Before triggering the pager:

image

After triggering the pager:

image

@mikesmithgh
Copy link
Owner

@musjj thanks for the screenshots.

  • What shell are you using? (bash, zsh, fish, etc)

  • Are there any errors during checkhealth?

nvim +'KittyScrollbackCheckHealth' +'quit!'
  • Could you run these two commands and let me know if it produces that same result?
kitty @ get-text --ansi --extent=all | nvim
kitty @ get-text --ansi --extent=all | sed -e "s/$/\x1b[0m/g" -e "s/\x1b\[\?25.\x1b\[.*;.*H\x1b\[.*//g" | nvim

I'm trying to determine if this is coming from Kitty or if it is any of the processing in the plugin.

@musjj
Copy link
Author

musjj commented Sep 18, 2023

I'm using zsh 5.9
I'm getting one healthcheck error, but I'm not sure if it's relevant:

kitty-scrollback: sed ~
- ERROR Failed to run healthcheck for "kitty-scrollback" plugin. Exception:
  ...unwrapped-9ec0ecb/share/nvim/runtime/lua/vim/_system.lua:241: ENOENT: no such file or directory

Running !sed --version inside nvim works just fine though.

kitty @ get-text --ansi --extent=all | nvim

I'm getting mixed results with this, but I'm not really sure why. Most of the time nvim don't end up displaying any contents. I also tried piping to nvim -u NONE with similar results. Piping to vim (9.0.1811) also yields similar results, but interestingly if I wait for a bit I can see the contents of the pipe flowing into the buffer gradually.

It feels like there's some kind of race condition when it comes to piping large text content, either from the kitty side or nvim side (or both?).

kitty @ get-text --ansi --extent=all | sed -e "s/$/\x1b[0m/g" -e "s/\x1b\[\?25.\x1b\[.*;.*H\x1b\[.*//g" | nvim

I'm seeing similar inconsistencies here, but in this case I usually get a tiny bit of content (some kind of terminal escape). But if I repeat the command enough I can sometimes get the complete scrollback of the terminal.

Sorry if there's a lot of vague-ness here, it's a weird issue. Can you reproduce this in your end? That might make debugging it easier.

@mikesmithgh
Copy link
Owner

@musjj Thanks for the info. I'm not able to reproduce the issue. I'll experiment around but any info you have will be helpful 👍

@musjj
Copy link
Author

musjj commented Sep 18, 2023

Tried to make it more reproducible:

base64 /dev/urandom | head -c 100000000
kitty @ get-text --ansi --extent=all | nvim -u NONE

Try increading the head number if the issue doesn't occur. At this point, this might not be a plugin issue but I'm still curious if someone else can reproduce it.

@mikesmithgh
Copy link
Owner

Tried to make it more reproducible:

base64 /dev/urandom | head -c 100000000
kitty @ get-text --ansi --extent=all | nvim -u NONE

Try increading the head number if the issue doesn't occur. At this point, this might not be a plugin issue but I'm still curious if someone else can reproduce it.

Awesome, thanks for this. I was able to reproduce on an Ubuntu VM. I couldn't reproduce on MacOS. I think you are right about Kitty or Nvim having issues with the large stdout/stdin. I'll try and dig more into this later to get a better understanding and may open an upstream ticket.

@mikesmithgh
Copy link
Owner

@musjj could you try

base64 /dev/urandom | head -c 100000000
nvim -u NONE <<< $(kitty @ get-text --ansi --extent=all)

This seems to work for me. This waits for the entire stdout before passing to NVIM.

@musjj
Copy link
Author

musjj commented Sep 18, 2023

This one works for me, it captures the entire scrollback! Can this workaround be used for the plugin?

@mikesmithgh
Copy link
Owner

This one works for me, it captures the entire scrollback! Can this workaround be used for the plugin?

Great. I'll have to make some changes but should be able to do it 👍

@mikesmithgh
Copy link
Owner

mikesmithgh commented Sep 19, 2023

Hey @musjj just an update. This may actually be a bug in Neovim. I'm going to dig in a little deeper and probably open an upstream ticket.

Edit: not a Neovim bug, just came across undocumented values for scrollback neovim/neovim#25245

@mikesmithgh
Copy link
Owner

@musjj so this is a tricky one 😂 . Ok I think I got it working now, would you mind doing a test with the branch fix-long-text-truncate ?

I added a statement to explicitly flush the buffer to stdout.

Not necessary, but you may also want to checkout the kitty option scrollback_pager_history_size if you want to increase the overall size of the scrollback.

@musjj
Copy link
Author

musjj commented Sep 19, 2023

Tested it out and it works perfectly, thanks a lot for the fix!

@mikesmithgh
Copy link
Owner

Tested it out and it works perfectly, thanks a lot for the fix!

🥳 awesome. Thanks for reporting and helping reproduce 👍. I'll have it merged to main probably sometime tomorrow.

mikesmithgh pushed a commit that referenced this issue Sep 19, 2023
## [1.0.2](v1.0.1...v1.0.2) (2023-09-19)

### Bug Fixes

* explicitly flush stdout for large scrollback closes [#7](#7) ([#11](#11)) ([3afc5a3](3afc5a3))
@mikesmithgh
Copy link
Owner

🎉 This issue has been resolved in version 1.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants