Lost newlines and repeated junk when copying text from terminal
- Dominant language
- Perl
- Stars
- 3.9k
- Forks
- 213
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
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:

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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.