概要
electron/main/ipc/search.test.ts の iterateWikilinkOccurrences 経由 test に、同一行に [[target]] が 2 回出る case の trim test を追加する。
iterateWikilinkOccurrences (search.ts:367-374) は callback 用に毎回新規 ref オブジェクトを alloc する設計で、PR #235 の helper-level trim はこの「per-yield 新規 alloc」前提に依存している。将来 helper が ref を pool/reuse するように refactor されると trim 効果が壊れる可能性。defensive な test で contract を lock。
背景
PR #235 /code-review max Phase 3 sweep で検出。defensive、優先度低。同 PR 本文の cancel test (39-#5) と同系統の「test gap を埋める」改善。
要件
electron/main/ipc/search.test.ts の scanBacklinksImpl (or scanUnresolvedWikilinksImpl) describe に以下のような test を追加:
it("trims each occurrence independently when [[target]] appears multiple times on the same line (#235)", async () => {
await writeFile(join(workspaceDir, "target.md"), "");
await writeFile(
join(workspaceDir, "src.md"),
" see [[target]] and [[target]] in the same line \n",
);
const out = await scanBacklinksImpl(TEST_WIN, workspaceDir, join(workspaceDir, "target.md"));
expect(out).toHaveLength(1);
expect(out[0].references).toHaveLength(2);
// 両 ref で同じ trim 済 lineContent (新規 ref が独立 alloc されていることを意図的に lock)
expect(out[0].references[0].lineContent).toBe("see [[target]] and [[target]] in the same line");
expect(out[0].references[1].lineContent).toBe("see [[target]] and [[target]] in the same line");
// byteOffset は別 (1 つ目と 2 つ目で異なる位置)
expect(out[0].references[0].byteOffset).not.toBe(out[0].references[1].byteOffset);
});
scanUnresolvedWikilinksImpl 側にも対称な test 追加で defensive coverage を上げる選択肢あり。
動作確認ポイント
関連ファイル
electron/main/ipc/search.test.ts (test 追加)
electron/main/ipc/search.ts:367-374 (test が lock する対象 contract)
参考
- PR #235 の skip 別 issue 候補 7
/code-review max Phase 3 sweep
概要
electron/main/ipc/search.test.tsのiterateWikilinkOccurrences経由 test に、同一行に[[target]]が 2 回出る case の trim test を追加する。iterateWikilinkOccurrences(search.ts:367-374) は callback 用に毎回新規 ref オブジェクトを alloc する設計で、PR #235 の helper-level trim はこの「per-yield 新規 alloc」前提に依存している。将来 helper が ref を pool/reuse するように refactor されると trim 効果が壊れる可能性。defensive な test で contract を lock。背景
PR #235
/code-review maxPhase 3 sweep で検出。defensive、優先度低。同 PR 本文の cancel test (39-#5) と同系統の「test gap を埋める」改善。要件
electron/main/ipc/search.test.tsのscanBacklinksImpl(orscanUnresolvedWikilinksImpl) describe に以下のような test を追加:scanUnresolvedWikilinksImpl側にも対称な test 追加で defensive coverage を上げる選択肢あり。動作確認ポイント
iterateWikilinkOccurrencesを将来 refactor した時に、ref pool 化のような変更が起きると本 test が落ちる (= contract lock 達成)関連ファイル
electron/main/ipc/search.test.ts(test 追加)electron/main/ipc/search.ts:367-374(test が lock する対象 contract)参考
/code-review maxPhase 3 sweep