diff --git a/CHANGELOG.md b/CHANGELOG.md index cde3865..e005bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,14 @@ While agsearch is on `0.x`, the CLI surface may still change between minor versions. Anything that changes it will be listed under **Changed** with the migration in the same line. +## [Unreleased] + +### Fixed + +- **`agsearch read` no longer crashes on superscript digits.** A message containing `¹` or + `²` raised `ValueError` while condensing line numbers, because `isdigit()` accepts + characters `int()` cannot parse. + ## [0.2.0] - 2026-09-05 Four more coding agents, and the transcript reader stops attributing machine diff --git a/agsearch b/agsearch index 3595c35..7a3966e 100755 --- a/agsearch +++ b/agsearch @@ -1190,10 +1190,10 @@ def _condense_line_numbers(s, minrun=4): toks = s.split(" ") out, i, n = [], 0, len(toks) while i < n: - if toks[i].isdigit(): + if toks[i].isdecimal(): last, chain = int(toks[i]), [i] for k in range(i + 1, n): - if toks[k].isdigit(): + if toks[k].isdecimal(): v = int(toks[k]) if 0 < v - last <= 3: # small gaps = blank lines in the file last, _ = v, chain.append(k) diff --git a/tests/test_transcript.py b/tests/test_transcript.py index a33d00b..68b31f9 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -94,6 +94,14 @@ def test_a_missing_session_says_so_instead_of_raising(self): self.assertIn("not found", buf.getvalue()) +class LineNumberCondenseTests(unittest.TestCase): + def test_superscript_digits_do_not_crash(self): + # "¹".isdigit() is True but int("¹") raises; a footnote marker crashed `read`. + ag = load_agsearch() + out = ag._condense_line_numbers("note ¹ 1 a 2 b 3 c 4 d ² end") + self.assertEqual(out, "note ¹ [file] d ² end") + + class BindingTests(unittest.TestCase): """ctrl-u and ctrl-d are fzf defaults (unix-line-discard, delete-char/eof). Rebinding them takes away "clear the query", which is the edit people reach