FIX - Add clickable hyperlinks when URLs are on screen #659 #734
+395
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a framebuffer artifact where hyperlink underlines could linger on rows below the last rendered document line.
Implemented hyperlink detection, styling, and Ctrl/Cmd+click navigation.
What / Where
src/buffer/mod.rs
Added lightweight hyperlink detection and caching (HyperlinkCache, LinkRange) and line‑level URL scanning.
In TextBuffer::render, track the last framebuffer row that contains document content and, after rendering, explicitly clear all remaining rows in the textarea viewport (text + fg/bg + attributes) so the diff sees them as changed.
Applied per‑line hyperlink styling (BrightCyan + underline) over the exact URL span.
src/tui.rs
For textareas, added Ctrl/Cmd+click handling: map click → document offset, resolve find_link_at_offset, and open the URL via start/open/xdg-open.
src/framebuffer.rs
Kept diffing model intact; no partial “dirty region” tracking, just used the new back‑buffer clears so rows below the last rendered line no longer carry stale styled pixels.
Why
Before: when hyperlink layout shrank upward, rows below the last rendered document line were never written into the back buffer, so front/back matched and the diff skipped them, leaving old underline/color data on screen.
After: TextBuffer::render always clears rows from last_rendered_row + 1 to the bottom of the textarea viewport, guaranteeing those rows change in the back buffer and get fully cleared in the terminal.
Tests
Automated:
cargo test (all unit tests and doctests pass).
Manual:
Open a file with long hyperlinks near the bottom of the viewport, edit/shorten the document or reflow so content moves up, and confirm no stale underlines remain below the last line.
Verify hyperlinks render underlined + cyan and that Ctrl/Cmd+click opens the correct URL.