Tabs at wrap column are lost when copying content
I sometimes copy and paste from iTerm windows into things like spreadsheets (especially Google Sheets). In order to make things appear in successive cells on these, I print a hard tab character. This works great, except if the data is a longish line (wider than my iTerm window) and wraps around... IF the tab is right at the point of wrapping, and I copy that data, that tab gets lost. Then I have to go back and edit my spreadsheet, fixing those cells having two cells' worth of data combined into one (and of course anything else to the right of that).
Repro
- Open Google Docs and start a new spreadsheet. (This also works with Excel and Numbers.)
- Open a new iTerm window, or hit Cmd-K to erase everything in an old one.
- Resize the iTerm window to, say, 60 x something. (So, 60 columns wide. Length/height doesn't matter. Mine is 60x43 at the moment. Use the handy size indicator at the top.)
- Run the attached shell script -- all it does is printf a bunch of lines of the form: some text (numbers), a tab character, the word HERE, and a newline. The numbers part keeps getting longer every line, and are in groups of 10 to make it easy to tell how long it is.
- Copy everything (simplest way is hit Cmd+A but you can also drag down the screen with the mouse, selecting text). I have the auto-copy feature turned on (so, whatever is selected is immediately copied) -- this is under Preferences > General > Selection > Copy to pasteboard on selection.
- Paste it into your spreadsheet of choice.
- To make it easy to see what's going on, resize your A column to be really wide.
Expected result: For each line, everything before the tab is in the first column, and everything after (the word HERE) is in the second. This should be consistent for the entire output.
Actual result: A bunch of them are like that, til you get to one whose number of chars before the tab is exactly the window width. Then 1-2 are screwed up (all the text is in the first column). Then, after that, it proceeds the regular way again.
Extra credit: Change (widen) the width of your iTerm window and copy/paste again. Notice that the results are the same. Also notice that for the two lines where it screws up, the word HERE is jammed right up next to the digits data -- all the other lines have a least one blank space where the tab character is.
(Theory: the tabs right at the end of physical line get removed from the output, most likely to keep the output from looking dumb on the following line -- extra whitespace or something. I bet somebody complained about this, early on.)
Below (and attached) is a test file I generated somehow (can't remember how, lol). Each line is one char longer than the previous ones. There are numbered columns and then a tab, and then "HERE" and a newline:
THundtMac$ cat tabtest.sh
#!/bin/bash
printf "123456\tHERE\n"
printf "1234567\tHERE\n"
printf "12345678\tHERE\n"
printf "123456789\tHERE\n"
printf "1234567890\tHERE\n"
printf " : \n"
printf "123456789-123456789-123456789-123456789-123456789-1\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-12\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-1234\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-12345\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-1234567\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-12345678\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-\tHERE\n"
printf "\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-1\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-12\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-1234\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-12345\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-1234567\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-12345678\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-\tHERE\n"
printf "\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-1\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-12\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-12345\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234567\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-12345678\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-\tHERE\n"
printf "\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12345\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234567\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-12345678\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789\tHERE\n"
printf "123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-\tHERE\n"
Thanks for your consideration!
(keywords: tab, character, eaten, dropped, wrapped, line, gone, disappeared)
Thanks for filing an issue! Please answer the questions below so I can help you.
-
iTerm2 version: Build 3.1.6beta1 (I don't think the version matters; this has been happening for a long while, at least a couple of years.)
-
OS version: MacOS 10.13.2, on MBP Mid 2015.
-
Attach ~/Library/Preferences/com.googlecode.iterm2.plist here (drag-drop from finder into this window) tabtest.shcom.googlecode.iterm2.plist
-
Attach a debug log, if possible. Instructions at https://iterm2.com/debuglog
-
Are you reporting a performance issue or a hang? Please attach a sample. Instructions at https://gitlab.com/gnachman/iterm2/wikis/HowToSample
-
Are you reporting a crash? Please attach the crash log. Instructions at https://gitlab.com/gnachman/iterm2/wikis/crash-logs
Detailed steps to reproduce the problem: 1. 2. 3.
What happened:
What should have happened: