Skip to content

Join transcript rows in getWordAtLocation for wrapped words (#5368) - #5378

Open
Soupboy006 wants to merge 1 commit into
termux:masterfrom
Soupboy006:fix/word-at-location-transcript-5368
Open

Soupboy006 wants to merge 1 commit into
termux:masterfrom
Soupboy006:fix/word-at-location-transcript-5368

Conversation

@Soupboy006

Copy link
Copy Markdown

Related to #5368 (tap-to-open truncates wrapped URLs).

What I verified first

I reproduced the tap path on JVM (TerminalEmulator + getWordAtLocation + TermuxUrlUtils.extractUrls): with the exact URL from #5368 printed fresh on an 80-column screen, tapping either visual line already returns and extracts the full URL on current master — the no-scroll case works.

The remaining truncation

What still truncates: a word wrapped across the transcript/screen boundary. If the head of a wrapped URL has scrolled into the transcript, tapping its visible tail returns only the on-screen part:

  • getWordAtLocation expands the tapped row upward with while (y1 > 0 ...), which stops at screen row 0 and never looks at transcript rows (negative external rows), even though getSelectedText fully supports them. The downward expansion has no such floor.
  • Reproduced: 107-char URL wrapped over transcript row -1 + screen row 0 → tap on row 0 returned only the 27-char tail, so extractUrls found no URL at all.

Fix (1 line, TerminalBuffer.getWordAtLocation)

Allow the upward expansion to reach -getActiveTranscriptRows(). The loop still strictly decreases and getSelectedText clamps out-of-range rows, so it always terminates. When there is no transcript the bound equals the old y1 > 0 check exactly, so on-screen behavior is unchanged.

Test

New testGetWordAtLocationAcrossTranscriptBoundary in ScreenBufferTest taps both ends of a URL wrapped over the boundary and asserts the full word both times (fails before, passes after — verified by executing the same scenario against the emulator).

Fixes the scrolled case of #5368.

Tapping the visible tail of a word wrapped across the transcript
boundary returned only the on-screen part, so tap-to-open saw a
truncated URL. The upward row expansion stopped at screen row 0 and
never looked into transcript rows. Allow it to expand down to
-activeTranscriptRows (getSelectedText already clamps and supports
negative rows).

Adds a regression test tapping both ends of a URL wrapped over the
transcript/screen boundary.
@limonlsiasm

Copy link
Copy Markdown

gh pr checkout 5378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants