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

Kitten clipboard non-deterministically copies/truncates big scrollback when piped tab @text by keybinding #1693

Closed
ronjouch opened this issue Jun 6, 2019 · 7 comments

Comments

@ronjouch
Copy link
Contributor

ronjouch commented Jun 6, 2019

To copy the whole scrollback to the clipboard, I use

map kitty_mod+a pipe @text tab kitty +kitten clipboard

With a small scrollback it works great, but with a big scrollback it consistently fails to copy the whole scrollback, instead truncating the end of the scrollback at non-deterministic positions 😕.

For example, after ls -la /usr/bin (2800 lines), when pressing kitty_mod+a,

  1. First press yields 2122 lines
  2. Second press yields 317 lines
  3. Third press yields 2635 lines

I'm using kitty master @ 4faf71b under Ubuntu 19.04, my shell is fish 3.0.2 .


Note: this is a followup of [Help] Map key to copying whole scrollback to clipboard, where I asked for advice to achieve the same result, using xclip/xsel. It worked, until it didn't, for reasons I didn't investigate, so I moved to kitten clipboard and was happy, then I noticed this problem.

@kovidgoyal
Copy link
Owner

Does using the clipboard kitten directly with a large text file work?

kitty +kitten clipboard < some text file

@ronjouch
Copy link
Contributor Author

ronjouch commented Jun 6, 2019

Does using the clipboard kitten directly with a large text file work?

kitty +kitten clipboard < some text file

@kovidgoyal yes this works consistently (same test case, with a ls.txt containing the same 2800 lines of ls -la /usr/bin/). Problem happens only when invoking the kitten from a binding, which opens a transient tab which gets closed after a few milliseconds. Maybe the transient tab is closed too soon / fails to wait for the kitten to finish?

And with that additional information, maybe my initial xsel-based solution actually suffers from the same problem?

As usual, thanks for the fast feedback.

@ronjouch
Copy link
Contributor Author

ronjouch commented Jun 6, 2019

Additional data point: this feels like a regression, I don't think I did encounter that back a few months ago. @kovidgoyal I could try a bisect, if that's helpful.

@ronjouch ronjouch changed the title Kitten clipboard non-deterministically copies/truncates big scrollback Kitten clipboard non-deterministically copies/truncates big scrollback when piped tab @text by keybinding Jun 6, 2019
@kovidgoyal
Copy link
Owner

Should be easy to fix, create a script that calls the kitten and sleeps
for a little while afterwards then use that in your binding.

kovidgoyal added a commit that referenced this issue Jun 7, 2019
@ronjouch
Copy link
Contributor Author

ronjouch commented Jun 7, 2019

@kovidgoyal I compiled 84fcabe and updated my config to map kitty_mod+a pipe @text tab kitty +kitten clipboard --wait-for-completion. Although it visibly waits, it now fails differently, truncating the beginning of a big scrollback and only keeping the end. In a terminal with a big scrollback of several ls -la /usr/bin, I get three only-slightly different outputs in my clipboard:

  1. First run: 11871 lines, 744.285 bytes.
  2. Second run: 11878 lines, 744.758 bytes.
  3. Third run: 11876 lines, 744.638 bytes.

My scrollback_lines is currently set to 100000, so it shouldn't be the problem.

Am I missing something?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 7, 2019

Just use

pipe @text clipboard dummy

@ronjouch
Copy link
Contributor Author

ronjouch commented Jun 7, 2019

Just use

pipe @text clipboard dummy

@kovidgoyal yes! That works muuuuuch better, it's reliable, flicker-less, and fast. Sorry, had focused on the first commit with --wait-for-completion but didn't see the contents of the second, adding the pipe command to send to clipboard.

Thanks for the fix and for the continued work on kitty 🙏 ! Good day/night.

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