peterh / liner

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

Paste input not displayed after #81 was fixed #86

Closed tsandall closed 7 years ago

tsandall commented 7 years ago

Hello! First of all, thanks for making a great library. I've been happily building a REPL on top of it for a little while now.

Description

Recently, I noticed an issue when pasting text containing newlines into the REPL. Specifically, liner doesn't display the pasted text, however, it seems that liner has received the text and passed it to the REPL.

I only noticed this after recently updating to the tip of master. I manually bisected the history and found that the behaviour changed with 2d7c636d2e41b3bdb8850667c7c977c97870bfbf (which fixed #81).

Steps to reproduce

It may be a bit tricky to reproduce this bug in isolation. The key (in my case) seems to be pasting text containing newlines. If the text doesn't contain a newline, it displays fine.

I can offer you a working example (on Mac):

torin:~$ cat >test <<EOF
> p :- true
> EOF
torin:~$ pbcopy < test
torin:~$ docker run -it --rm openpolicyagent/opa:0.2.1
OPA 0.2.1 (commit b3f62a1, built at 2016-11-23T16:33:13Z)

Run 'help' to see a list of commands.

> p :- true
>

Note: the paste happens on the first non-empty line after "Run 'help' to see [...]", i.e., "> p :- true".

When I do the same with openpolicyagent/opa:0.2.2, I only see an empty line:

torin:~$ docker run -it --rm openpolicyagent/opa:0.2.2
OPA 0.2.2 (commit fb9e6c7, built at 2016-12-01T01:41:03Z)

Run 'help' to see a list of commands.

>
>

In v0.2.1 OPA is using 8975875355a81d612fafb9f5a6037bdcc2d9b073 and in v0.2.2 OPA is using 3c5f577f62ec95a012ea48a58dd4de3c48222a35. This is what I get for not pinning dependencies with Glide.

Additional Info

peterh commented 7 years ago

Sorry for the slow reply. I was away when your bug report came in, and I forgot about it when I got back.

I wasn't able to reproduce this bug, but I think I see how it happens. I just pushed a change that should fix it. Could you please test bf27d3ba8e1d9899d45a457ffac16c953eb2d647 and let me know? Thanks.

tsandall commented 7 years ago

Updated to bf27d3b and did not see the problem. LGTM.

peterh commented 7 years ago

Great! Thanks for testing.