mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-12-07 17:41:08 +01:00
Fix crash with wide character in last column
Ignore wide character outputs instead of crashing when the cursor is in the last column with autowrap disabled.
This commit is contained in:
parent
4ccc703fcf
commit
b54c7909bd
2 changed files with 22 additions and 7 deletions
|
|
@ -2156,15 +2156,22 @@ public final class TerminalEmulator {
|
|||
|
||||
final boolean autoWrap = isDecsetInternalBitSet(DECSET_BIT_AUTOWRAP);
|
||||
final int displayWidth = WcWidth.width(codePoint);
|
||||
final boolean cursorInLastColumn = mCursorCol == mRightMargin - 1;
|
||||
|
||||
if (autoWrap && (mCursorCol == mRightMargin - 1 && ((mAboutToAutoWrap && displayWidth == 1) || displayWidth == 2))) {
|
||||
mScreen.setLineWrap(mCursorRow);
|
||||
mCursorCol = mLeftMargin;
|
||||
if (mCursorRow + 1 < mBottomMargin) {
|
||||
mCursorRow++;
|
||||
} else {
|
||||
scrollDownOneLine();
|
||||
if (autoWrap) {
|
||||
if (cursorInLastColumn && ((mAboutToAutoWrap && displayWidth == 1) || displayWidth == 2)) {
|
||||
mScreen.setLineWrap(mCursorRow);
|
||||
mCursorCol = mLeftMargin;
|
||||
if (mCursorRow + 1 < mBottomMargin) {
|
||||
mCursorRow++;
|
||||
} else {
|
||||
scrollDownOneLine();
|
||||
}
|
||||
}
|
||||
} else if (cursorInLastColumn && displayWidth == 2) {
|
||||
// The behaviour when a wide character is output with cursor in the last column when
|
||||
// autowrap is disabled is not obvious - it's ignored here.
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInsertMode && displayWidth > 0) {
|
||||
|
|
|
|||
|
|
@ -84,4 +84,12 @@ public class UnicodeInputTest extends TerminalTestCase {
|
|||
assertLineIs(0, "\uFFFDY ");
|
||||
}
|
||||
|
||||
public void testWideCharacterWithoutWrapping() throws Exception {
|
||||
// With wraparound disabled. The behaviour when a wide character is output with cursor in
|
||||
// the last column when autowrap is disabled is not obvious, but we expect the wide
|
||||
// character to be ignored here.
|
||||
withTerminalSized(3, 3).enterString("\033[?7l").enterString("枝枝枝").assertLinesAre("枝 ", " ", " ");
|
||||
enterString("a枝").assertLinesAre("枝a", " ", " ");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue