UNPKG

@pierre/diffs

Version:

32 lines (30 loc) 860 B
import { normalizeDiffResolution } from "./normalizeDiffResolution.js"; import { resolveRegion } from "./resolveRegion.js"; //#region src/utils/diffAcceptRejectHunk.ts function diffAcceptRejectHunk(diff, hunkIndex, options) { const hunk = diff.hunks[hunkIndex]; if (hunk == null) { console.error({ hunkIndex, diff }); throw new Error("diffAcceptRejectHunk: Invalid hunk index"); } return resolveRegion(diff, { resolution: normalizeDiffResolution(options), hunkIndex, ...(() => { if (typeof options === "object") return { startContentIndex: options.changeIndex, endContentIndex: options.changeIndex }; return { startContentIndex: 0, endContentIndex: Math.max(0, (hunk.hunkContent.length ?? 1) - 1) }; })() }); } //#endregion export { diffAcceptRejectHunk }; //# sourceMappingURL=diffAcceptRejectHunk.js.map