peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.04k stars 132 forks source link

Paste and tabs #114

Open tsandall opened 5 years ago

tsandall commented 5 years ago

This is more of a question than a bug or feature request.

I've noticed my tab completion function is called when users paste text into a REPL built on top of liner. I'm wondering if anyone else has run into this. The problem is that the tab completion function returns a candidate which breaks the input.

It looks like some terminals support bracketed paste mode which allows programs to have different behaviour between regular input and paste. I could imagine using this disable tab completion during paste operations.

/ref https://github.com/open-policy-agent/opa/issues/962

peterh commented 4 years ago

Interesting suggestion. I was not aware of bracketed paste mode.

I'm not quite sure what to do with bracketed paste mode. Certainly tabs should not be allowed as literal characters in a paste if the user cannot type a literal tab. But should liner eat the tabs silently instead of treating them as completion tokens? I'm not sure. The existence of bracketed paste mode suggests that most people would prefer tabs to be eaten silently. I'd be intrigued to see how invasive a pull request might be.

tsandall commented 4 years ago

But should liner eat the tabs silently instead of treating them as completion tokens? I'm not sure.

I think so. IOW, while a bracketed paste is being performed, no tab completion would occur from tabs in the input. When the bracketed paste is ended (by the escape code on that page), liner would return the full pasted input.