Skip to content

Commit

Permalink
Terminal.input() does not work on Windows, fixes #237
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 7, 2018
1 parent 1ee156d commit ae62ec8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions terminal/src/main/java/org/jline/utils/NonBlocking.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private NonBlockingReaderInputStream(NonBlockingReader reader, Charset charset,
this.chars = CharBuffer.allocate(bufferSize);
// No input available after initialization
this.bytes.limit(0);
this.chars.limit(0);
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions terminal/src/test/java/org/jline/utils/NonBlockingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ public void testNonBlockingPumpReader() throws IOException {
assertEquals('中', nbr.read(100));
assertEquals(NonBlockingReader.READ_EXPIRED, nbr.read(100));
}

@Test
public void testNonBlockStreamOnReader() throws IOException {
NonBlockingPumpReader reader = NonBlocking.nonBlockingPumpReader();
NonBlockingInputStream is = NonBlocking.nonBlockingStream(reader, StandardCharsets.UTF_8);
reader.getWriter().write("a");
assertEquals('a', is.read(1000L));
}
}

0 comments on commit ae62ec8

Please # to comment.