From fb92babee7a4cb7ae7d1d32d1f24431ca07a8cc2 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 24 Feb 2026 15:31:43 +0900 Subject: [PATCH] refactor(hashline-edit): remove dead applyInsertBetween function This function is no longer called from edit-operations.ts after the op/pos/end/lines schema refactor in PR #2079. Remove the function definition and its 3 dedicated test cases. --- node_modules | 1 + .../edit-operation-primitives.ts | 26 ----------------- .../hashline-edit/edit-operations.test.ts | 28 +------------------ 3 files changed, 2 insertions(+), 53 deletions(-) create mode 120000 node_modules diff --git a/node_modules b/node_modules new file mode 120000 index 000000000..a930a2065 --- /dev/null +++ b/node_modules @@ -0,0 +1 @@ +/Users/yeongyu/local-workspaces/oh-my-opencode/node_modules \ No newline at end of file diff --git a/src/tools/hashline-edit/edit-operation-primitives.ts b/src/tools/hashline-edit/edit-operation-primitives.ts index 43904011c..43a235450 100644 --- a/src/tools/hashline-edit/edit-operation-primitives.ts +++ b/src/tools/hashline-edit/edit-operation-primitives.ts @@ -103,32 +103,6 @@ export function applyInsertBefore( return result } -export function applyInsertBetween( - lines: string[], - afterAnchor: string, - beforeAnchor: string, - text: string | string[], - options?: EditApplyOptions -): string[] { - if (shouldValidate(options)) { - validateLineRef(lines, afterAnchor) - validateLineRef(lines, beforeAnchor) - } - const { line: afterLine } = parseLineRef(afterAnchor) - const { line: beforeLine } = parseLineRef(beforeAnchor) - if (beforeLine <= afterLine) { - throw new Error(`insert_between requires after_line (${afterLine}) < before_line (${beforeLine})`) - } - - const result = [...lines] - const newLines = stripInsertBoundaryEcho(lines[afterLine - 1], lines[beforeLine - 1], toNewLines(text)) - if (newLines.length === 0) { - throw new Error(`insert_between requires non-empty text for ${afterAnchor}..${beforeAnchor}`) - } - result.splice(beforeLine - 1, 0, ...newLines) - return result -} - export function applyAppend(lines: string[], text: string | string[]): string[] { const normalized = toNewLines(text) if (normalized.length === 0) { diff --git a/src/tools/hashline-edit/edit-operations.test.ts b/src/tools/hashline-edit/edit-operations.test.ts index eb0adbaf0..ce573da4c 100644 --- a/src/tools/hashline-edit/edit-operations.test.ts +++ b/src/tools/hashline-edit/edit-operations.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "bun:test" import { applyHashlineEdits, applyInsertAfter, applyReplaceLines, applySetLine } from "./edit-operations" -import { applyAppend, applyInsertBetween, applyPrepend } from "./edit-operation-primitives" +import { applyAppend, applyPrepend } from "./edit-operation-primitives" import { computeLineHash } from "./hash-computation" import type { HashlineEdit } from "./types" @@ -56,16 +56,6 @@ describe("hashline edit operations", () => { expect(result).toEqual("line 1\nbefore 2\nline 2\nline 3") }) - it("applies insert_between with dual anchors", () => { - //#given - const lines = ["line 1", "line 2", "line 3"] - - //#when - const result = applyInsertBetween(lines, anchorFor(lines, 1), anchorFor(lines, 2), ["between"]).join("\n") - - //#then - expect(result).toEqual("line 1\nbetween\nline 2\nline 3") - }) it("throws when insert_after receives empty text array", () => { //#given @@ -85,13 +75,6 @@ describe("hashline edit operations", () => { ).toThrow(/non-empty/i) }) - it("throws when insert_between receives empty text array", () => { - //#given - const lines = ["line 1", "line 2"] - - //#when / #then - expect(() => applyInsertBetween(lines, anchorFor(lines, 1), anchorFor(lines, 2), [])).toThrow(/non-empty/i) - }) it("applies mixed edits in one pass", () => { //#given @@ -215,15 +198,6 @@ describe("hashline edit operations", () => { expect(result).toEqual(["before", "new 1", "new 2", "after"]) }) - it("throws when insert_between payload contains only boundary echoes", () => { - //#given - const lines = ["line 1", "line 2", "line 3"] - - //#when / #then - expect(() => applyInsertBetween(lines, anchorFor(lines, 1), anchorFor(lines, 2), ["line 1", "line 2"])).toThrow( - /non-empty/i - ) - }) it("restores indentation for first replace_lines entry", () => { //#given