Hello!
First time using JLine and it's awesome. However, running into a small issue (or expected behavior?) for a possible corner case. In a call to LineReader#readLine, if the user has anything typed and then inputs Ctrl-D, the expected EndOfFileException is seemingly not thrown and nothing happens. It seems that Ctrl-D is only handled when the input is empty.
I'm writing my application in Scala, but here's a minimal example of Java code that reproduces the issue:
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
boolean running = true;
LineReader reader = LineReaderBuilder.builder().build();
while (running) {
try {
String line = reader.readLine(">> ");
System.out.println("ECHO: " + line);
} catch (UserInterruptException e) {
System.out.println("^C, new prompt");
} catch (EndOfFileException e) {
System.out.println("^D, exiting");
running = false;
}
}
reader.getTerminal().close();
}
}
If I run this and have typed anything after the prompt, in order to exit the application I need to clear my input and input Ctrl-D, or input Ctrl-C to get to a new prompt followed by a Ctrl-D on the new empty prompt.
For what it's worth, Ctrl-C does not behave the seem. Regardless of what has been typed after a prompt, Ctrl-C always raises a UserInterruptException. In my opinion, this seems like the correct behavior and Ctrl-D should behave similarly.
This isn't a major issue, but was hoping for some clarification/direction. Using JLine version 3.26.3.
Thanks!
-Derek