Skip to content

Commit

Permalink
LineReader encounters exception if tabs used in dummy terminal, fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 15, 2019
1 parent 81e4c07 commit 886867c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4750,7 +4750,7 @@ else if (item instanceof List) {

@SuppressWarnings("unchecked")
protected void toColumns(Object items, int width, int maxWidth, AttributedStringBuilder sb, Candidate selection, String completed, boolean rowsFirst, int[] out) {
if (maxWidth <= 0) {
if (maxWidth <= 0 || width <= 0) {
return;
}
// This is a group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jline.reader.impl.completer.ArgumentCompleter;
import org.jline.reader.impl.completer.NullCompleter;
import org.jline.reader.impl.completer.StringsCompleter;
import org.jline.terminal.Size;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -144,4 +145,12 @@ public void testMenuOrder() {
assertLine("ab_helloWorld ", new TestBuffer("a\t\t\n\n"));
}

@Test
public void testDumbTerminalNoSizeComplete() {
terminal.setSize(new Size());
reader.setCompleter(new StringsCompleter(Arrays.asList("ae_helloWorld", "ad_helloWorld", "ac_helloWorld", "ab_helloWorld", "aa_helloWorld")));

assertLine("a", new TestBuffer("a\t\n\n"));
}

}

0 comments on commit 886867c

Please sign in to comment.