Skip to content
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

Command completion fails when value starts with escape character: org.jline.reader.EOFError #364

Closed
offbynull opened this issue Mar 6, 2019 · 0 comments

Comments

@offbynull
Copy link

When terminal is created with a default parser and eofOnEscapedNewLine is set to true, tab completion on value that starts with '' will fail to EOFError exception.

Terminal terminal = TerminalBuilder.builder().build();

Completer completer = new StringsCompleter("foo", "bar", "baz");

DefaultParser parser = new DefaultParser();
parser.setEofOnEscapedNewLine(true);

LineReader reader = LineReaderBuilder.builder()
        .terminal(terminal)
        .completer(completer)
        .parser(parser)
        .build();

while (true) {
    String line = null;
    try {
        line = reader.readLine("prompt >", null, (MaskingCallback) null, null);
    } catch (UserInterruptException e) {
        // Ignore
    } catch (EndOfFileException e) {
        return;
    }

    if (line == null) {
        continue;
    }

    line = line.trim();

    terminal.writer().println(line);
}
prompt >test \Mar 06, 2019 1:56:14 PM org.jline.utils.Log logr
INFO: Error while parsing line
org.jline.reader.EOFError: Escaped new line
        at org.jline.reader.impl.DefaultParser.parse(DefaultParser.java:213)
        at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:3971)
        at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:3894)
        at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3506)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:587)
        at com.netrias.ade.shell.Shell.startShell(Shell.java:48)
        at com.netrias.ade.shell.Shell.main(Shell.java:28)


prompt >

Issue may be related to #257.

mattirn added a commit to mattirn/jline3 that referenced this issue Mar 12, 2019
@gnodet gnodet closed this as completed in e1b0fde Mar 15, 2019
gnodet added a commit that referenced this issue Mar 15, 2019
gnodet added a commit that referenced this issue Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant