From 6e1995ce69158905852d3d6dfea8cf6e2cb1a8c5 Mon Sep 17 00:00:00 2001 From: Jonas Haugesen Date: Thu, 20 Aug 2026 09:46:52 +0200 Subject: [PATCH] Fixed: drain session scroll counter on attach so viewport-hold never consumes stale background-streamed deltas The emulator's scroll counter keeps growing while a session is not being viewed (onTextChanged() skips the screen update - and clearScrollCounter() - when the changed session is not current or the activity is not visible). attachSession() reset the view state but left the counter intact: the first screen update after attaching would hand the whole stale delta to the viewport-hold logic, which treats it as "rows appended just now" and pins the view thousands of lines deep into the scrollback, making scrolling appear dead in that session. Discard the counter on attach - the user starts at the live bottom. versionCode 1024 / versionName 0.119.0-titan2.2 --- app/build.gradle | 4 ++-- .../src/main/java/com/termux/view/TerminalView.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5cc9a8bb..7aed1e24 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,8 +43,8 @@ android { defaultConfig { minSdkVersion project.properties.minSdkVersion.toInteger() targetSdkVersion project.properties.targetSdkVersion.toInteger() - versionCode 1023 - versionName "0.119.0-titan2.1" + versionCode 1024 + versionName "0.119.0-titan2.2" if (appVersionName) versionName = appVersionName validateVersionName(versionName) diff --git a/terminal-view/src/main/java/com/termux/view/TerminalView.java b/terminal-view/src/main/java/com/termux/view/TerminalView.java index 34f05b10..e18e51b3 100644 --- a/terminal-view/src/main/java/com/termux/view/TerminalView.java +++ b/terminal-view/src/main/java/com/termux/view/TerminalView.java @@ -303,6 +303,17 @@ public final class TerminalView extends View { mHardwareShiftDown = false; // TITAN2 PATCH mHardwareAltDown = false; // TITAN2 PATCH + // TITAN2 PATCH: discard the session's scroll-delta that accumulated while it was not + // being viewed. Output keeps flowing in the background, but onTextChanged() skips the + // screen update - and with it clearScrollCounter() - when the session is not current or + // the activity is not visible. If that stale counter survived until the first + // onScreenUpdated() after this attach, the viewport-hold logic below would treat all of + // it as "rows appended just now" and pin the view thousands of lines deep into the + // scrollback, stranding the user far from the live output (scrolling appears dead in + // this session while other sessions behave normally). Start from the live bottom clean. + TerminalEmulator emulator = session.getEmulator(); + if (emulator != null) emulator.clearScrollCounter(); + mTermSession = session; mEmulator = null; mCombiningAccent = 0;