You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is line 1.
This is line 2.
This is line 3.
This is line 4.
This is line 5.
This is line 6.
This is line 7.
This is line 8.
This is line 9.
This is line 10.
Now run the example program and paste these10 lines into it. This is what you get:
$ ./linenoise_example hello> This is line 1. echo: 'This is line 1.' hello>
Only the first line is received. Lines 2 - 9 are ignored. Each line should be printed with a prompt and a response. Pasting short code snippets into a REPL is a very common thing to do.
The text was updated successfully, but these errors were encountered:
I think I found the explanation for this problem in the linux termios man page where it explains the TCSAFLUSH flag to tcsetattr:
the change occurs after all output written to the object
referred by fd has been transmitted, and all input that
has been received but not read will be discarded before
the change is made.
That flag is used in disableRawMode. So everything in the input buffer after the first newline gets discarded when disableRawMode is called after processing the first line.
The fix for this appears to be to use TCSADRAIN instead of TCSAFLUSH. That drains the output but does not discard the input.
tung
added a commit
to tung/clox
that referenced
this issue
Dec 16, 2022
When pasting multiple lines into the REPL before, only the first line
would be recognized; this change allows all pasted lines to go through.
See also: antirez/linenoise#208
Highlight and copy the 10 lines below:
This is line 1.
This is line 2.
This is line 3.
This is line 4.
This is line 5.
This is line 6.
This is line 7.
This is line 8.
This is line 9.
This is line 10.
Now run the example program and paste these10 lines into it. This is what you get:
$ ./linenoise_example
hello> This is line 1.
echo: 'This is line 1.'
hello>
Only the first line is received. Lines 2 - 9 are ignored. Each line should be printed with a prompt and a response. Pasting short code snippets into a REPL is a very common thing to do.
The text was updated successfully, but these errors were encountered: