MCPcopy Create free account
hub / github.com/anomalyco/opencode / findDiffSide

Function findDiffSide

packages/session-ui/src/pierre/diff-selection.ts:5–16  ·  view source on GitHub ↗
(node: HTMLElement)

Source from the content-addressed store, hash-verified

3export type DiffSelectionSide = "additions" | "deletions"
4
5export function findDiffSide(node: HTMLElement): DiffSelectionSide {
6 const line = node.closest("[data-line], [data-alt-line]")
7 if (line instanceof HTMLElement) {
8 const type = line.dataset.lineType
9 if (type === "change-deletion") return "deletions"
10 if (type === "change-addition" || type === "change-additions") return "additions"
11 }
12
13 const code = node.closest("[data-code]")
14 if (!(code instanceof HTMLElement)) return "additions"
15 return code.hasAttribute("data-deletions") ? "deletions" : "additions"
16}
17
18export function diffLineIndex(split: boolean, node: HTMLElement) {
19 const raw = node.dataset.lineIndex

Callers 2

diffSelectionSideFunction · 0.90
diffRowIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected