Fix scrolling in Terminal

This commit is contained in:
James Babcock committed 2026-07-24 01:52:12 -07:00
1 parent 8ffccad7f0
commit d42e11e2a5
7 files changed
+90 -63

No files matched your search

+2 -7
View File
@@ -4,10 +4,10 @@ import { BATTERY_ICON_WIDTH, drawBattery } from "../../graphics/battery";
import { readActiveNotificationIcons } from "../../native/notification-icons";
import { readPhoneBatteryState } from "../../native/phone-battery";
import { noteStaleDataUsed, renderPassAllowsStaleData } from "../../util/render-freshness";
import { clamp } from "../../util/numeric-util";
import { renderIcon, type IconName } from "../../graphics/icons";
import { batteryDisplayModeSetting, timeFormatSetting } from "../dashboard-settings";
import { Layer } from "../layers";
import { scrollToKeepSelectionVisible } from "../menu";
import { SHELL_OPAQUE_BLACK, SIDEBAR_WIDTH, TOP_BAR_HEIGHT } from "./geometry";
const ICON_SIZE = 32;
@@ -112,12 +112,7 @@ export class ShellChromeLayer implements Layer {
const listHeight = G2_LENS_HEIGHT - listTop - 10;
const visibleCount = Math.max(1, ((listHeight + ICON_SPACING) / itemStride) | 0);
const count = state.windows.length;
if (state.selectedIndex < this.scrollRow) {
this.scrollRow = state.selectedIndex;
} else if (state.selectedIndex >= this.scrollRow + visibleCount) {
this.scrollRow = state.selectedIndex - visibleCount + 1;
}
this.scrollRow = clamp(this.scrollRow, 0, Math.max(0, count - visibleCount));
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, state.selectedIndex, visibleCount, count);
const lastVisible = Math.min(count, this.scrollRow + visibleCount);
// The selection is a "diversion" of the sidebar/main separator line: the
+2 -7
View File
@@ -8,7 +8,7 @@ import {
GESTURE_SCROLL,
} from "../gestures";
import { DashboardInputEvent, Layer, LayerActions, LayerContext } from "../layers";
import { drawSelectionHighlight } from "../menu";
import { drawSelectionHighlight, scrollToKeepSelectionVisible } from "../menu";
import { createInProcessWindow } from "./in-process-window";
import { shell, type ShellWindow } from "./shell";
@@ -89,12 +89,7 @@ class LauncherGridLayer implements Layer {
const colW = width / COLS;
// Scroll to keep the selected row among the fully-visible rows.
if (this.selectedRow < this.scrollRow) {
this.scrollRow = this.selectedRow;
} else if (this.selectedRow > this.scrollRow + FULL_ROWS - 1) {
this.scrollRow = this.selectedRow - (FULL_ROWS - 1);
}
this.scrollRow = clamp(this.scrollRow, 0, Math.max(0, rows - FULL_ROWS));
this.scrollRow = scrollToKeepSelectionVisible(this.scrollRow, this.selectedRow, FULL_ROWS, rows);
const rowY = (row: number) => GRID_TOP + (row - this.scrollRow) * rowH;