📝 3_Code_Change_Report.mdv4.2 · 2026-09-05

Code Change Report

File: PDFsearch.py Function: search(), phrase-mode ("literal") branch Line: 334 (pre-fix) Change type: One-line logic fix, no structural/interface change

Diff

--- PDFsearch.py (before)
+++ PDFsearch.py (after)
@@ -331,7 +331,7 @@
if _is_wildcard(pw):
matched_keys = _matching_words(pw, word_index)
else:
- matched_keys = [pw] if pw in word_index else []
+ matched_keys = folded_index.get(pw.lower(), [])
pages = set()
for w in matched_keys:
pages.update(tuple(m) for m in word_index.get(w, []))

What changed

Phrase-mode's plain-word (non-wildcard) lookup now folds through the same case-insensitive folded_index mechanism that word-mode search already uses, instead of doing a raw case-sensitive exact-key check against word_index directly.

What did NOT change

Behavioral consequence worth flagging

This makes phrase-mode search case-insensitive across the board, matching word-mode's existing behavior. True case-sensitive phrase matching was not actually possible against this index even before this fix's intent — the index itself has been lowercase-only since PDFIndexer.py's case-folding was introduced; the old code's apparent case-sensitivity was a non-functional artifact (it could only ever match an already-lowercase quoted phrase), not a real, working feature being removed.

Verification performed

See Problem & Resolution Report for full test detail (test_phrase_bug.py). Patched file confirmed to compile cleanly (python3 -m py_compile) with no syntax errors introduced.

Deployment status