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

Display NPE #490

Closed
mattirn opened this issue Dec 18, 2019 · 1 comment
Closed

Display NPE #490

mattirn opened this issue Dec 18, 2019 · 1 comment
Labels
bug
Milestone

Comments

@mattirn
Copy link
Collaborator

@mattirn mattirn commented Dec 18, 2019

Got NPE when using tab-completion:

 java.lang.NullPointerException: null
        at org.jline.utils.Display.wcwidth(Display.java:491) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.toColumns(LineReaderImpl.java:5173) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.computePost(LineReaderImpl.java:5152) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.computePost(LineReaderImpl.java:5105) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.doList(LineReaderImpl.java:4990) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.doList(LineReaderImpl.java:4977) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4591) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4362) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:4301) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl$1.apply(LineReaderImpl.java:3796) ~[jline-3.13.3-SNAPSHOT.jar:?]
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:665) ~[jline-3.13.3-SNAPSHOT.jar:?]

Method wcwidth() could be robusted as

    public int wcwidth(String str) {
        return str != null ? AttributedString.fromAnsi(str).columnLength() : 0;
    }
@mattirn mattirn added the bug label Dec 18, 2019
@mattirn mattirn added this to the 3.13.3 milestone Dec 18, 2019
@gnodet

This comment has been minimized.

Copy link
Member

@gnodet gnodet commented Dec 18, 2019

Agreed, but I would also change the Candidate constructor to avoid the problem:

    public Candidate(String value, String displ, String group, String descr, String suffix, String key, boolean complete) {
        this.value = Objects.requireNonNull(value);
        this.displ = Objects.requireNonNull(displ);
       ...
    }
@mattirn mattirn closed this in 0e537cb Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.