-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readLine() ignores any text in the buffer when OEF is reached #298
Comments
You're right. When the terminal is not an interactive terminal (with a human being), it does not make sense to try to read Ctrl-D in advance. I'll try to investigate. |
On unix systems, the |
Just a note on the dumb terminal idea-- just because I've piped input to the process doesn't mean that I'm not running it in a terminal capable of ANSI formatting, etc. In fact, in my cases I likely would be which I reported as another issue here; #299 |
Yes, this is the same issue. But not a simple bug to fix, it may require some important changes in order to split the input from the output. |
@gnodet Any progress on this? What if, when the OEF is reached, if there is input that's been read into the buffer, the line is read (returned from |
@mattirn I see this ticket has been closed. Can you please elaborate on what change you made or if I need to modify any code on my end to take advantage of it? |
You have to catch jline3/demo/src/main/java/org/jline/demo/Repl.java Lines 341 to 351 in fd11775
|
@mattirn Thanks, I'll make these changes in my console app. |
@mattirn @gnodet Oops, it seems something has gotten broken since I originally put this ticket in. This simple example of piping commands to a text file into my console app no longer works:
On Windows, using the JansiWinSysTerminal, I get the following error that appears in the console:
The I am not able to confirm this ticket is fixed. |
I attempted another approach to this, with not piping input to the process, but instead typing some text into the buffer and then pressing Ctrl-D. Interestingly enough, when I press Ctrl-D, instead of throwing the I'm not sure if this is an inteded behavior or not. I can confirm that when I press Ctrl-D without any text in the buffer, it throws the |
Also Ubuntu/xterm zsh will complete when you press Ctrl-D if the buffer is not empty. The ticket I have tested only using Windows/CMD and it does work also with JLine version 3.18.0. |
jline3/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java Lines 653 to 655 in 29d72f8
|
Interesting, that doesn't make any sense to me, but no matter. I've admittedly never tried it before so let's just ignore that behavior and focus on the error above that's preventing me from using the changes in this ticket.
Ok, so "works on your machine" but let's figure out why it's not working for me. I've pasted the exception I received above. Can you comment on what that exception might mean or why I'd be getting it?
|
@bdw429s hard to tell the reason as the underlying problem is hidden. I've raised an issue in jansi to report the real problem. That should help understanding the issue. |
@mattirn Thanks for spending some time on this. Is the commit above meant to be a fix, or simply some additional debugging code? May I recommend adding a comment to tickets when adding commits or closing them? I see a lot of mystery commits on tickets in this repo where I'm not sure what the current status of the ticket really is or what has been done against it. :) |
Fixed and tested using ConEmu with Jansi and JNA. |
@mattirn Excellent, and thanks for the update. I'll give this a test soon on my end. |
CommandBox allows you to pipe a file of commands into it and readLine() will read the lines one at a time off the standard input just as though a human had typed them.
If there's no trailing line break at the end of the file, then the last command is read in but the OEF fires before the last line is handed back for execution. I get that this makes some deal of sense since I can press Ctrl-D while typing at the shell to exit immediately, but in the case of reading an actual text file input, I'd like to be able to execute that last line even if there's no line break at the end.
The
org.jline.reader.UserInterruptException
exception providesgetPartialLine()
to see if the user typed something. Is the correct fix to add the partial line to theorg.jline.reader.EndOfFileException
as well?The text was updated successfully, but these errors were encountered: