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

Lost newlines and repeated junk when copying text from terminal #862

Open
sultanqasim opened this issue Dec 4, 2024 · 1 comment
Open

Comments

@sultanqasim
Copy link

In this example, I open a fresh a-Terminal session, display a file on screen with cat, copy its text, and paste it in this GitHub issue. Note that extra newlines got added before and after the selected text, and the newlines after the shebang line and function got lost.

Selected text:
IMG_0321

Copied text:


[~/Documents]$ cat repro5.sh 
#! /bin/sh
foo() {
        printf "baa "
        printf "caa "
        printf "daa "
}
foo | tr 'a' 'z'
printf "\n"

In some other cases, particularly when I’ve been repeatedly opening and closing and editing files, or when I’m struggling a bit to get text selection to cooperate, I end up with bigger mismatches between what is shown selected on screen and what actually gets copied, such as lines or entire paragraphs/functions repeated. This issue is rather tricky to reproduce and actual behaviour seems to vary. Nonetheless, there do seem to be bugs in the text selection and/or text copying logic for the terminal.

The main issues I see are:

  1. Blank lines in selected text are usually lost in what is copied.
  2. Sometimes, copied text has blank lines prepended and appended.
  3. Sometimes lines or groups of lines get repeated/duplicated in the copied text.
@holzschu
Copy link
Owner

holzschu commented Dec 5, 2024

While I'm looking for ways to fix this one, you can use the pbcopy command: cat repro5.sh | pbcopy or pbcopy < repro5.sh for a reliable copy (there is also pbpaste).

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