fix(edit): validate args, preserve CRLF, allow truly-empty result (#401, #404, #409)#417
Merged
fix(edit): validate args, preserve CRLF, allow truly-empty result (#401, #404, #409)#417
Conversation
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
…suming seq When applyEdit is called with op=.insert and after=null, the switch case falls through without modifying the line buffer, but the function still proceeds to atomically rewrite the file and call recordEdit. The result is a phantom store entry (seq incremented, ChangeEntry recorded) for an operation that did nothing visible. This pollutes changesSince() and makes seq numbers unreliable as causality markers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…yEdit
When applyEdit operates on a CRLF file, splitScalar('\n') leaves the
trailing '\r' attached to each unchanged line. The new replacement line
inherits whatever line ending the caller supplied (typically none / LF),
and the rejoin uses bare '\n'. Result: the on-disk file has mixed CRLF
on unchanged lines and bare LF on changed lines, breaking tools that
detect file-wide line ending style.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When applyEdit replaces the only line of a file with empty content, the post-processing unconditionally restores the source's trailing newline. The result is that 'replace line 1..1 with ""' on file 'abc\n' leaves '\n' on disk instead of an empty file. Callers asking for an empty file get a non-empty file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThresholds: 10.00% and 50,000 ns absolute delta
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #401, #404, #409. Three coherent fixes to applyEdit's args validation, line-ending preservation, and zero-byte result handling. All 3 issue tests pass; full suite green.