Files
oh-my-pi/packages/coding-agent/test/core
Miroslav Drbal [ApoC] 27d951ea37 fix(patch): HASHLINE_PREFIX_RE incorrectly strips comment lines matching '# Word:' pattern (#334)
* fix(patch): HASHLINE_PREFIX_RE strips comment lines with word: pattern

The regex used [0-9a-zA-Z]{1,16} for the hash ID segment, which matched
common comment patterns like '# Note:', '# TODO:', '# FIXME:'. When a
single-line replacement contained such a comment, nonEmpty===1 and
hashPrefixCount===1, triggering stripping and eating the comment prefix.

Actual hashline IDs are always exactly 2 chars from ZPMQVRWSNKTXJBYH.
Constrain the regex to that exact alphabet so no English word can match.

Also update tests that used fake IDs (AB, CD, EF) not in the real alphabet.

* test(patch): add regression tests for comment line prefix stripping bug

Three new tests in hashlineParseContent describe block:
- hashlineParseText preserves '# Word:' comment lines (unit)
- full pipeline: replacing '# Note:' comment line preserves prefix
- full pipeline: replacing '# TODO:' comment line preserves prefix

These would have caught the HASHLINE_PREFIX_RE bug where [0-9a-zA-Z]{1,16}
matched comment words, causing stripNewLinePrefixes to eat the '# Note:'
prefix when a single comment line was the sole replacement entry.

---------

Co-authored-by: Miroslav Drbal <miroslav.drbal@gendigital.com>
2026-03-09 14:59:52 +01:00
..