From 91fc2209b93462f5f126131463d437a7d5e9ab86 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 11 Dec 2025 14:19:44 -0800 Subject: [PATCH] Fix conflicts --- web_src/js/features/repo-diff-selection.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web_src/js/features/repo-diff-selection.ts b/web_src/js/features/repo-diff-selection.ts index 7d4f70efeb..04ea1f9b20 100644 --- a/web_src/js/features/repo-diff-selection.ts +++ b/web_src/js/features/repo-diff-selection.ts @@ -25,7 +25,7 @@ function isDiffAnchorId(id: string | null): boolean { return id !== null && id.startsWith('diff-'); } -function parseDiffAnchor(anchor: string | null): DiffAnchorInfo | null { +function parseDiffAnchor(anchor: string): DiffAnchorInfo | null { if (!isDiffAnchorId(anchor)) return null; const suffixMatch = diffAnchorSuffixRegex.exec(anchor); if (!suffixMatch) return null; @@ -184,7 +184,7 @@ export async function highlightDiffSelectionFromHash(): Promise { function handleDiffLineNumberClick(cell: HTMLElement, e: MouseEvent) { let span = cell.querySelector('span[id^="diff-"]'); - let info = parseDiffAnchor(span?.id ?? null); + let info = parseDiffAnchor(span?.id ?? ''); // If clicked cell has no line number (e.g., clicking on the empty side of a deletion/addition), // try to find the line number from the sibling cell on the same row @@ -197,7 +197,7 @@ function handleDiffLineNumberClick(cell: HTMLElement, e: MouseEvent) { row.querySelector('td.lines-num-old'); if (siblingCell) { span = siblingCell.querySelector('span[id^="diff-"]'); - info = parseDiffAnchor(span?.id ?? null); + info = parseDiffAnchor(span?.id ?? ''); } if (!info) return; } @@ -219,7 +219,7 @@ function handleDiffLineNumberClick(cell: HTMLElement, e: MouseEvent) { diffSelectionStart = null; // Remove hash from URL completely window.history.replaceState(null, '', window.location.pathname + window.location.search); - window.getSelection().removeAllRanges(); + window.getSelection()?.removeAllRanges(); return; } } @@ -245,7 +245,7 @@ function handleDiffLineNumberClick(cell: HTMLElement, e: MouseEvent) { if (!e.shiftKey || !diffSelectionStart || diffSelectionStart.container !== container || diffSelectionStart.fragment !== info.fragment) { diffSelectionStart = {...info, container}; } - window.getSelection().removeAllRanges(); + window.getSelection()?.removeAllRanges(); } }