mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix(mobile): find the caret line from the absolute cursor row on a parked viewport
xterm's cursorY is relative to baseY, but _tapIsOnCaretLine read it as a screen row. With the viewport parked above the bottom (a tab switch onto a frame with trailing blank rows) a tap on a URL typed in the prompt opened it, and a URL in scrollback on the row cursorY happened to name stayed inert.
This commit is contained in:
1 parent
ce809eac41
commit
d6d9315fb6
2 files changed
+44
-9
No files matched your search
@@ -2356,15 +2356,17 @@ Object.assign(CodemanApp.prototype, {
|
||||
if (!buffer?.getLine) return false;
|
||||
const pos = this._clientPointToCell(clientX, clientY);
|
||||
if (!pos) return false;
|
||||
const rows = Math.max(1, this.terminal.rows || 1);
|
||||
const cursorRow = Math.max(0, Math.min(rows - 1, buffer.cursorY || 0));
|
||||
const tappedRow = pos.row - 1;
|
||||
if (tappedRow === cursorRow) return true;
|
||||
let start = cursorRow;
|
||||
while (start > 0 && buffer.getLine(buffer.viewportY + start)?.isWrapped) start--;
|
||||
let end = cursorRow;
|
||||
while (end + 1 < rows && buffer.getLine(buffer.viewportY + end + 1)?.isWrapped) end++;
|
||||
return tappedRow >= start && tappedRow <= end;
|
||||
// Compare ABSOLUTE buffer lines: cursorY is baseY-relative and the tap is
|
||||
// viewport-relative, so they only agree while the viewport sits at the bottom
|
||||
// (a tab switch parks it above, see scrollToLastNonEmptyLine).
|
||||
const cursorLine = buffer.baseY + (buffer.cursorY || 0);
|
||||
const tappedLine = buffer.viewportY + pos.row - 1;
|
||||
let start = cursorLine;
|
||||
while (start > 0 && buffer.getLine(start)?.isWrapped) start--;
|
||||
let end = cursorLine;
|
||||
// Bounded by length: xterm's getLine wraps around its circular list past the end.
|
||||
while (end + 1 < buffer.length && buffer.getLine(end + 1)?.isWrapped) end++;
|
||||
return tappedLine >= start && tappedLine <= end;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user