hyper: Pasting into nano removes line breaks
-
I am on the latest Hyper.app version
-
I have searched the issues of this repo and believe that this is not a duplicate
-
OS version and name: OSX 10.12.3
-
Hyper.app version: 1.1.0 (1.1.0.1408)
-
Link of a Gist with the contents of your .hyper.js: https://gist.github.com/pento/ec0a96a33be6fc98ec93559ba68ce7fb
-
Relevant information from devtools (CMD+SHIFT+I on Mac OS, CTRL+SHIFT+I elsewhere): N/A
-
The issue is reproducible in vanilla Hyper.app: Reproducible with plugins disabled, didn’t try vanilla.
Issue
When pasting text into nano, newline characters are removed.
To reproduce:
- Copy some text with line breaks in it. It doesn’t matter where the text is copied from.
- Open
nano - Press Cmd+V
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 18
- Comments: 40 (1 by maintainers)
I’m still working at debugging this via the xterm.js demo. There are a decent amount of paste issues on both xterm.js and vscode (which forked xterm.js I believe). It just seems like the issue is deeper than this client which is built on top of xterm and electron but hopefully I’ll have it solved by tomorrow.
Edit: Just an update
I was able to fix this with a modification to xterm.js - however I don’t fully understand why it works thus I’m trying to test some things on windows/ubuntu/osx which is taking me a while.
The closest to an explanation is this jediterm issue which explains that newlines should be sent to a terminal via the
\raka^Mcharacter. This can be shown viashowkeyin any terminal. The issue then is that pasted strings containing newlines send the\naka^Jwhich causes weird behavior.Hopefully I’ll have a better understanding of the issue tomorrow and some tests to make sure the fix works as expected.
Alright - more reading and I finally understand the issue.
In short: The fix is to translate
\nto\ras @menzow initially described. I will open a PR in xterm.js.note Hyper uses a fork of xterm.js which will need to pull in the fix when it’s merged.
In case you want to understand what’s going on:
This seems to be a bug in any terminal program which doesn’t implement bracketed paste mode (or properly implement it in the case of joe). As noted in this nano bug other editors which don’t paste properly include joe and dit. You’ll notice when you paste with newlines, each of the above editors interprets
\naka^Jto a function. e.g. nano follows pico, and pico decided^J(ctrl+j) should be used to justify content. Programs without bracketed paste mode may still behave properly in the case of newlines because, similar to emacs,^Jwill be mapped to a newline character as expected.I just experienced this as well.
If I change the files newline option from
LFtoCRLFI get a different result.Let’s use the following text as an example;
If the file is set with
LFI get the following result when pasting my text;If I then change to CRLF I get the following result;
None are correct. But this may point someone in the right direction when debugging this issue.
macOS Sierra:
Menu --> Edit --> Pasteseems to resolve this (not ideal, but hey it works)@Scukerman Thank you for your up 😃
@olsonpm Sorry I haven’t seen your question. I will merge your xterm PR in my fork ASAP.
Does anyone care about this issue? We could celebrate a year of inactivity in a couple of months.
It has already been merged in my used fork: https://github.com/chabou/xterm.js/commit/855964fbe10099410edb6dc85ed6b7940130649c
I tried to reproduce without any success. Can anybody confirm me that it has been fixed in our last canary (v2.0.0-canary.16)?
@Scukerman thank you for your feedback. I’m using zsh too and I can’t reproduce 😦
Can you try to reproduce on v2 available on
canaryupdate channel?@Scukerman In any case, PRs are very welcome.
A good example of this is pasting a certificate (in PEM format). It seems it ignores newlines until the content would overflow and then it honours them.