agl / xmpp-client

An XMPP client with OTR support
BSD 3-Clause "New" or "Revised" License
365 stars 71 forks source link

pasting tab-idented text sends it to the wrong person(s) #52

Closed leif closed 9 years ago

leif commented 10 years ago

Hitting tab repeatedly cycles through contacts, changing the recipient of the next message. This leads to a hilarious/disastrous failure mode when you paste tab-indented text, such as source code (without using /paste mode): different lines are sent to different people, depending on the indentation level of each line.

Perhaps pasting could be detected similarly to the way irssi does it?

agl commented 10 years ago

Do you know how irssi does it? I might guess that it looks for larger reads from the terminal, which is possible, but seems a little error prone.

isislovecruft commented 10 years ago

Irssi removes tabs by joining lines according to the logic documented here, in irssi.git/src/fe-text/gui-readline.c. This is what causes source code pasted into Irssi to sometimes be a complete disaster.

Rather than following irssi's example, I assume the safest thing to do would be to replace tabs in pasted input with two/four/eight spaces, given that xmpp-client's tab-completion will complete even if no printable characters have been typed.

agl commented 9 years ago

There's a start to the problem: that'll stop tabs at the beginning of the line from autocompleting – although they'll still be suppressed.

What I did find, and I wish I knew about before, was that some terminals support bracketed paste mode: http://cirw.in/blog/bracketed-paste

I've a change out for review to add support for that to ssh/terminal and that'll solve the problem in a better way: https://codereview.appspot.com/171330043

agl commented 9 years ago

With a modern terminal, this should Just Work after b216508f9003f4fffc13cb418df322559562871d. (That commit needs an updated version of code.google.com/p/go.crypto/ssh/terminal too.)