Fix crash when using some unicode characters

We should never try to look at characters in a row after those
actually used.
This commit is contained in:
Fredrik Fornwall
2015-11-13 00:14:35 +01:00
parent 89912be500
commit 09ecd14764

View File

@@ -80,6 +80,7 @@ final class TerminalRenderer {
TerminalRow lineObject = screen.allocateFullLineIfNecessary(screen.externalToInternalRow(row)); TerminalRow lineObject = screen.allocateFullLineIfNecessary(screen.externalToInternalRow(row));
final char[] line = lineObject.mText; final char[] line = lineObject.mText;
final int charsUsedInLine = lineObject.getSpaceUsed();
int lastRunStyle = 0; int lastRunStyle = 0;
boolean lastRunInsideCursor = false; boolean lastRunInsideCursor = false;
@@ -125,7 +126,7 @@ final class TerminalRenderer {
measuredWidthForRun += measuredCodePointWidth; measuredWidthForRun += measuredCodePointWidth;
column += codePointWcWidth; column += codePointWcWidth;
currentCharIndex += charsForCodePoint; currentCharIndex += charsForCodePoint;
while (WcWidth.width(line, currentCharIndex) <= 0) { while (currentCharIndex < charsUsedInLine && WcWidth.width(line, currentCharIndex) <= 0) {
// Eat combining chars so that they are treated as part of the last non-combining code point, // Eat combining chars so that they are treated as part of the last non-combining code point,
// instead of e.g. being considered inside the cursor in the next run. // instead of e.g. being considered inside the cursor in the next run.
currentCharIndex += Character.isHighSurrogate(line[currentCharIndex]) ? 2 : 1; currentCharIndex += Character.isHighSurrogate(line[currentCharIndex]) ? 2 : 1;