peterh/liner

Paste and tabs

tsandall opened this issue · 2 comments

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 open-policy-agent/opa#962

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.

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.