Blob view: click/drag line-number selection with shareable #L links (single line and ranges) #243
Labels
No labels
actions
bug
cli
duplicate
enhancement
fork
forum
git storage
help wanted
insights
invalid
issues
moderation
oidc
ownership transfer
packages
pr/merge protection rules
projects
pull requests
question
releases
sponsorships
tags
webhooks
wiki
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crueber/walhub#243
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What's requested
In the Code tab's blob view, clicking a line number should highlight that line and update the URL so the selection is shareable; clicking and dragging across multiple line numbers should highlight the whole range. This is the GitHub
#L12/#L12-L20model.Current state (code evidence)
<pre>elements (web/src/pages/Blob.jsx:139-146): the gutter is one<pre class="blob-gutter">with all numbers joined by\n(:140-142), the code is another<pre class="code-view">with a single highlighted<code innerHTML>(:143-145). There are no per-line elements at all — noids, no per-line DOM nodes — so nothing is targetable by a fragment and there is nothing to click per line.user-select: none(web/css/repo.css:25) and both<pre>s are plain blocks — no click handlers exist inBlob.jsx(no signal for selection, nouseSearchParams/hash read)./:owner/:name/blob/*rest(web/src/index.jsx:68);Blob.jsxalready reads path/ref fromuseResolved+useRepo. No URL state for lines today..blob-gutterand.code-viewset matchingline-height: 1.45/ font metrics (repo.css:24-28), which is what keeps the two-column scroll aligned — any per-line restructure must preserve that pairing exactly or the columns desync.Proposed design (for implementer)
<table>(GitHub-style: line-number cell + code cell per row) or a flex column of paired cells. Keep the tokenizer output per line (lib/highlight.jsalready tokenizes; splitting highlighted HTML by line must respect multi-line tokens — verify the tokenizer never spans lines, or tokenize per line). Scroll behavior stays on the container (.blob-colskeepsoverflow: auto).mousedownon a line number sets the anchor line;mousemoveover other numbers extends the focus end (drag);mouseupfinalizes.#L12.#Lstart-Lend.#L12or#L12-L20(GitHub-compatible). Use the router's hash handling orlocation.hashdirectly; replacing history state (not pushing) on each drag frame avoids history spam — push once onmouseup. On load, parse the hash and highlight + scroll the first selected line into view..line-hlbackground rule (theme-aware, both light/dark — the repo uses zinc/emerald Tailwind tokens +var(--panel)/var(--bg)in repo.css); anchor end lines can get a stronger edge. Highlight must apply to both gutter number and code cell so the row reads as one unit.Acceptance criteria
#L<n>in the URL; copying that URL and opening it re-renders with the line highlighted and scrolled into view.#L<start>-L<end>; dragging upward and downward both normalize to ascending order.#L12-L20URL highlights the range on load, including in a fresh tab (state comes from the URL, not session).line-height, horizontal scroll still moves both columns together).#Ltarget doesn't require loading anything extra (client-side only; no API change).#L/#L-L), per the settingsNav.js headless-test precedent.Fix is up: #256 (branch fix/issue-243, not merged). Per-line table code view with click/drag/shift gutter selection and shareable #L12/#L12-L20 URLs; per-line tokenization (block-comment spans can cross newlines, verified); both themes; keyboard accessible via native #L anchors. node suite 481/481 green, vite build verified. Browser interaction pass is open — shared-daemon guard blocks target attach/loopback.
Review of PR #256 (fix/issue-243, blob line selection):
VERIFIED (scratch worktree /tmp/pr256, since removed):
FIXED + PUSHED to origin/fix/issue-243 (08a3d9f, re-tested 10/10 + vite clean):
NON-BLOCKING NOTES:
RECOMMENDATION: ready to merge (after author confirms the real-Chromium pass already noted open in the doc).
Fixed by PR #256 incl. review keyboard/blur-drag fixes (single-table pairing, shareable #L links; 481/481), merged. Closing.