Open aeneasr opened 6 years ago
The REPL has basic tab completion support. I think the problem is the completion handler running when the user pastes text into the REPL. We should check if the line reader library (peterh/liner) has a way to deal with this. Other REPLs must have dealt with this in the past.
Looks like the terminal feature to support here is called "bracketed paste", see this blog post: https://cirw.in/blog/bracketed-paste. To actually work, it depends on a cooperative terminal emulator, but nowadays most seem to support it (anecdata: iterm2).
@srenatus thanks for researching this. From reading the first link you posted, it seems like we'd need to modify the peterh/liner package to properly handle the start/stop escape sequences (it doesn't seem to do this currently.) I'm going to open an issue on peterh/liner to see if they have any ideas.
I've been suffering from this for a while. This would be a lot less painful if opa fmt
used spaces for indentation. Would an option to enable this be reasonable, since it looks like the upstream bracketed paste change isn't likely?
I feel like adding an option to opa fmt
is a slippery slope as it's intended to be the "one true format" for rego. If we open the door to customization, we'll certainly end up with other options in future.
I'm tempted to just replace liner with another, more featureful readline implementation. There are a bunch of options that weren't available when we originally picked liner. https://github.com/AlecAivazis/survey looks like it's actively maintained, though it might have more features than we need.
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.
If I copy (cmd+c) the following snippet (with
\t
)and paste it (right-click -> paste), then OPA shows:
If I copy the same snippet but replace
\t
with e.g. 4 spacesOPA works fine:
This is happens for me on the OSX terminal as well as Windows cmd.exe