Skip to content

Commit d2e628c

Browse files
FourWindffclaude
andcommitted
fix(diff): handle double-click in blank area for all line types
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>
1 parent a02c58a commit d2e628c

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

src/components/ScrollingDiffView.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -895,24 +895,17 @@ export function ScrollingDiffView(props: ScrollingDiffViewProps) {
895895
// For double-clicks (detail >= 2) outside a diff line, prevent the
896896
// browser from creating its "snap to nearest text" selection at all,
897897
// so the user doesn't see a brief blue flash on the last diff line.
898+
// Note: this fires on the second mousedown of the sequence — the
899+
// first mousedown of a double-click has detail === 1.
898900
if (e.detail >= 2) {
899901
const target = e.target as HTMLElement | null;
900-
if (!target?.closest('[data-new-line]')) {
902+
if (!target?.closest('[data-line-type]')) {
901903
e.preventDefault();
902904
}
903905
}
904906
}
905907

906-
function onMouseUp(e: MouseEvent) {
907-
// Ignore clicks that didn't land on a diff line. Without this, a
908-
// double-click in the blank area below the last file collapses the
909-
// browser's "snap to nearest text" selection onto the previous line
910-
// and incorrectly opens the inline input.
911-
const target = e.target as HTMLElement | null;
912-
if (!target?.closest('[data-new-line]')) {
913-
if (!pendingInput()) setHighlightedRange(null);
914-
return;
915-
}
908+
function onMouseUp() {
916909
requestAnimationFrame(() => {
917910
const sel = getDiffSelection();
918911
if (!sel) {

0 commit comments

Comments
 (0)