fix(diff): ignore double-click in blank area outside diff lines#104
fix(diff): ignore double-click in blank area outside diff lines#104FourWindff wants to merge 2 commits intojohannesjo:mainfrom
Conversation
Double-clicking in the empty area below the last file caused the browser to snap-select the nearest text node (the last diff line), which both flashed a stray highlight and incorrectly opened the inline input. Bail out of the mouseup handler when the click target isn't inside a diff line, and preventDefault on mousedown for double-clicks outside diff lines so the browser never creates the ghost selection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the fix! The 1. Removed lines are accidentally treated as "outside a diff line."
Suggested predicate: 2. A user drag-selecting from line 5 down past the last hunk and releasing over the blank padding has 3. The With Minor: Listener pairing + cleanup and the "why" comments look good — just want to make sure removed-line interactions and drag-selects ending in blank space aren't collateral damage. |
Refine the blank-area double-click fix to use [data-line-type] instead of [data-new-line], so it works consistently for all diff line types. Also remove the now-redundant onMouseUp guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Applied all three suggestions:
|
|
Thanks for the quick turnaround — the three changes look correct. A few smaller follow-ups before merge: 1. Form-field carve-out (important). The new 2. Gate on 3. Type narrowing instead of All three roll into something like: function onMouseDown(e: MouseEvent) {
if (e.button \!== 0 || e.detail < 2) return;
const target = e.target;
if (\!(target instanceof Element)) return;
if (target instanceof HTMLElement && (
target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable
)) return;
if (\!target.closest('[data-line-type]')) e.preventDefault();
}Otherwise LGTM. |
|
Thanks for the detailed review! I'm genuinely curious — how did you spot these edge cases? Would love to understand the thought process so I can catch similar issues myself next time. Thanks again! |
|
Hey hey @FourWindff ! I am using claude code to do a code review and then I usually do a quick superficial check if the findings make any sense or not. A manual review would be better of course, but I simply don't have the time to do it super thourougly each time. |
Would you mind sharing what your process or skill is? I can then do this before I submit a PR :) FYI I've been using a combination of claude, codex and occasionally gemini (when I hit quota). I've found GPT-5.4+ is stronger than Opus 4.7 but I still mostly use claude (sonnet 4.6) |
Summary
Double-clicking in the empty area below the last file (or between files) caused two glitches: