clipboard kitten: Dont set clipboard when getting clipboard

The previous behavior meant getting the clipboard would
first empty it if STDIN was null or empty which can easily happen when
run non-interactively.

Fixes #6302
This commit is contained in:
Kovid Goyal 2023-05-25 08:41:55 +05:30
parent 5e6d020275
commit 20fbde447c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 2 deletions

View file

@ -48,6 +48,8 @@ Detailed list of changes
- clipboard kitten: Fix a bug causing the last MIME type available on the clipboard not being recognized when pasting
- clipboard kitten: Dont set clipboard when getting clipboard in filter mode (:iss:`6302`)
- Fix regression in 0.28.0 causing color fringing when rendering in transparent windows on light backgrounds (:iss:`6209`)
- show_key kitten: In kitty mode show the actual bytes sent by the terminal rather than a re-encoding of the parsed key event

View file

@ -99,7 +99,9 @@ func run_plain_text_loop(opts *Options) (err error) {
stdin_is_tty := tty.IsTerminal(os.Stdin.Fd())
var data_src io.Reader
var tempfile *os.File
if !stdin_is_tty {
if !stdin_is_tty && !opts.GetClipboard {
// we dont read STDIN when getting clipboard as it makes it hard to use the kitten in contexts where
// the user does not control STDIN such as being execed from other programs.
data_src, tempfile, err = preread_stdin()
if err != nil {
return err

View file

@ -50,7 +50,7 @@ Read or write to the system clipboard.
This kitten operates most simply in :italic:`filter mode`.
To set the clipboard text, pipe in the new text on :file:`STDIN`. Use the
:option:`--get-clipboard` option to output the current clipboard text content to
:option:`--get-clipboard` option to instead output the current clipboard text content to
:file:`STDOUT`. Note that copying from the clipboard will cause a permission
popup, see :opt:`clipboard_control` for details.