mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
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:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user