- History data: stores multiline expressions with real \n — correct… #74
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
seq-lisp-2-backport
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/seq-lisp!74
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "newline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
…, untouched
The multiline display with ... and indentation is deferred to the full multiline editor project (the 5-7 day design doc). For now, recalled expressions
are editable single lines with all vi motions working.
PR Review: History Data vs Presentation Separation
This is a well-motivated fix. The design doc clearly articulates the problem (history entries containing real newlines being corrupted by the newline-as-delimiter storage format), and Option A (escape embedded newlines as
\n, backslashes as\\) is a pragmatic choice that keeps the file human-readable.The stack manipulation logic in the new routines traces correctly. Here are my observations:
Missing Tests
The biggest gap.
test_history.seqtests basic add/get operations but has no coverage for the new functionality. Expected cases:escape-newlines/unescape-newlinesround-trip, including strings with literal backslasheshistory-to-string, thenhistory-load-lines, and verify the original string is recoveredflatten-newlines: verify a string with embedded newlines becomes space-separatedstring-strip-leading: leading spaces/tabs/newlines, already-clean strings, all-whitespace stringThe checkpoints in the design doc map directly to test cases -- translating them into assertions in
test_history.seqwould be a natural next step.Backward Compatibility Gap
Existing
~/.seqlisp_historyfiles that contain backslash sequences (e.g. a history entry like(display "\n")) will be misread on first load: the two-char\nwill be unescaped to a real newline, corrupting that entry. This is a one-time migration issue that self-heals after the next save/load cycle, but worth a brief note in the design doc or a code comment nearhistory-load-lines.Comment Placement
string-strip-leading(line 338) was inserted immediately after this comment:This makes the comment appear to describe the helper, not
history-add. Moving the helper before that comment block (or giving it its own section header) would be cleaner.Performance (minor)
All four new loop functions build strings one character at a time, giving O(n^2) behaviour due to string concatenation. For REPL history lines this is fine in practice, but worth noting if these routines are ever reused on larger inputs.
Logic Looks Correct
Key paths traced:
unescape-newlines-loopcorrectly handles\n-> newline,\\-> backslash, and the single-char remainder edge caseescape-newlines-loopreplaces\->\\before checking newlines ->\n(order matters, and it is right)string-strip-leading-loopcorrectly usesdup/2 pickto callstring.char-atwithout consumingStroff the stackflatten-newlinescalls at the two recall sites are in the right place: history data stays clean, only the editor buffer gets the space-flattened versionSummary
The approach is sound and the implementation is correct. Main ask before merging: add tests, especially the persistence round-trip. The backward compatibility note is minor but worth documenting somewhere.