Skip to content

Commit

Permalink
Fix cursor computation when using a mask
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 7, 2017
1 parent b3eb67b commit 3e402db
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3286,11 +3286,21 @@ protected void redisplay(boolean flush) {

int cursorPos = -1;
if (size.getColumns() > 0) {
// TODO: buf.upToCursor() does not take into account the mask which could modify the display length
// TODO: in case of wide chars
AttributedStringBuilder sb = new AttributedStringBuilder().tabs(TAB_WIDTH);
sb.append(prompt);
sb.append(insertSecondaryPrompts(new AttributedString(buf.upToCursor()), secondaryPrompts, false));
String buffer = buf.upToCursor();
if (mask != null) {
if (mask == NULL_MASK) {
buffer = "";
} else {
StringBuilder nsb = new StringBuilder();
for (int i = buffer.length(); i-- > 0; ) {
nsb.append((char) mask);
}
buffer = nsb.toString();
}
}
sb.append(insertSecondaryPrompts(new AttributedString(buffer), secondaryPrompts, false));
List<AttributedString> promptLines = sb.columnSplitLength(size.getColumns(), false, display.delayLineWrap());
if (!promptLines.isEmpty()) {
cursorPos = size.cursorPos(promptLines.size() - 1,
Expand Down

0 comments on commit 3e402db

Please sign in to comment.