Skip to content

kitten clipboard foo.txt skips even-numbered 4 KiB chunks #7858

@benblank

Description

@benblank

Describe the bug

When copying a text file to the clipboard using kitten clipboard foo.txt, only the first/third/fifth/etc. 4 KiB chunks seem to make it to the clipboard. I've seen this when pasting into Firefox, VSCodium, and into a new file using kitten clipboard -g bar.txt. Piping a text file into kitten clipboard doesn't seem to have the issue.

To Reproduce

Steps to reproduce the behavior:

  1. Create a text file at least 4,096 bytes in size:

    yes 1 | head -c 4096 > example.txt
    yes 2 | head -c 4096 >> example.txt
    yes 3 | head -c 4096 >> example.txt
    yes 4 | head -c 2048 >> example.txt

    (The first 4 KiB of example.txt will consist of lines containing the number 1, the second 4 KiB the number 2, the third 4 KiB the number 3, and the last 2 KiB the number 4. This is purely illustrative; the contents of the file don't seem to affect the issue.)

  2. Copy and paste using kitten clipboard:

    kitten clipboard < example.txt
    kitten clipboard -g from-stdin.txt
    kitten clipboard example.txt
    kitten clipboard -g from-arg.txt
  3. Check the file sizes using e.g. ls -l example.txt from-stdin.txt from-arg.txt. You should see that example.txt and from-stdin.txt are both 14 KiB (14,336 bytes), but from-arg.txt is only 8 KiB (8,192 bytes).

  4. Checking the contents of from-arg.txt, it won't contain any even numbers:

    # Will find 4,096 lines with 1 or 3.
    grep '[13]' example.txt | wc -l
    grep '[13]' from-stdin.txt | wc -l
    grep '[13]' from-arg.txt | wc -l
    
    # Will find 3,072 lines with 2 or 4.
    grep '[24]' example.txt | wc -l
    grep '[24]' from-stdin.txt | wc -l
    
    # Will find zero lines with 2 or 4.
    grep '[24]' from-arg.txt | wc -l

Environment details

kitty 0.36.2 created by Kovid Goyal
Linux cyclone 6.10.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 09 Sep 2024 02:38:45 +0000 x86_64
Arch Linux 6.10.9-arch1-1 (/dev/tty)

Running under: Wayland (kwin 6.1.4) missing: single_pixel_buffer
OpenGL: '4.6 (Core Profile) Mesa 24.2.2-arch1.1' Detected version: 4.6
Frozen: False
Fonts:
  medium: NotoSansMono-Regular: /usr/share/fonts/noto/NotoSansMono-Regular.ttf:0
          Features: ()
    bold: NotoSansMono-Bold: /usr/share/fonts/noto/NotoSansMono-Bold.ttf:0
          Features: ()
  italic: NotoSansMono-Regular: /usr/share/fonts/noto/NotoSansMono-Regular.ttf:0
          Features: ()
      bi: NotoSansMono-Bold: /usr/share/fonts/noto/NotoSansMono-Bold.ttf:0
          Features: ()
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /usr/bin/bash

Config options different from defaults:

Important environment variables seen by the kitty process:
	PATH                                /home/five35/bin:/home/five35/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin
	LANG                                en_US.UTF-8
	VISUAL                              /usr/bin/codium
	EDITOR                              /usr/bin/nano
	SHELL                               /usr/bin/bash
	DISPLAY                             :0
	WAYLAND_DISPLAY                     wayland-0
	USER                                five35
	XDG_CONFIG_DIRS                     /home/five35/.config/kdedefaults:/etc/xdg
	XDG_SESSION_PATH                    /org/freedesktop/DisplayManager/Session1
	XDG_MENU_PREFIX                     plasma-
	XDG_SEAT                            seat0
	XDG_SESSION_DESKTOP                 KDE
	XDG_SESSION_TYPE                    wayland
	XDG_CURRENT_DESKTOP                 KDE
	XDG_SEAT_PATH                       /org/freedesktop/DisplayManager/Seat0
	XDG_SESSION_CLASS                   user
	XDG_VTNR                            2
	XDG_SESSION_ID                      2
	XDG_RUNTIME_DIR                     /run/user/1000

Additional context

The behavior is the same under kitty --config NONE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions