Skip to content

Commit

Permalink
Fix wide characters displaying, fixes #431
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jan 5, 2020
1 parent b4ee6d9 commit 94a83fd
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions terminal/src/main/java/org/jline/utils/Display.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2019, the original author or authors.
* Copyright (c) 2002-2020, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -207,17 +207,15 @@ public void update(List<AttributedString> newLines, int targetCursorPos, boolean
// go to next line column zero
rawPrint(new AttributedString(" \b"));
} else {
AttributedString firstChar =
newLine.columnSubSequence(0, 1);
AttributedString firstChar = newLine.substring(0, 1);
// go to next line column one
rawPrint(firstChar);
cursorPos++;
int firstLength = firstChar.length(); // normally 1
newLine = newLine.substring(firstLength, newLength);
newLength -= firstLength;
if (oldLength >= firstLength) {
oldLine = oldLine.substring(firstLength, oldLength);
oldLength -= firstLength;
cursorPos += firstChar.columnLength(); // normally 1
newLine = newLine.substring(1, newLength);
newLength--;
if (oldLength > 0) {
oldLine = oldLine.substring(1, oldLength);
oldLength--;
}
currentPos = cursorPos;
}
Expand Down Expand Up @@ -321,7 +319,6 @@ public void update(List<AttributedString> newLines, int targetCursorPos, boolean
currentPos = cursorPos;
}
}
int was = cursorPos;
if (cursorPos != targetCursorPos) {
moveVisualCursorTo(targetCursorPos < 0 ? currentPos : targetCursorPos, newLines);
}
Expand Down

0 comments on commit 94a83fd

Please sign in to comment.