Document resyntax/grimoire/string-replacement#790
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The string-too-short error in string-replacement-render was reported under the name string-apply-replacement, a copy-paste slip. Additionally, a replacement's required length now accounts for its end position, not just the positions its copied pieces refer to. Applying a replacement to a string shorter than the replaced region previously skipped the friendly error and failed inside make-string with a confusing contract violation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
The pieces making up a string replacement's contents are now called string pieces, with a string-piece struct supertype underneath both kinds and a public string-piece? predicate. The pieces aren't exclusively tied to replacements --- syntax-replacement uses their spans directly when narrowing replacement focus --- so the replacement-string-span operation is now string-piece-span, and contracts say string-piece? instead of enumerating the two kinds. Also converts copied-string from define-tuple-type to a plain struct, matching inserted-string. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
The Narrowing the Focus of Replacements section now has a tag so the string-replacement-normalize docs can point at it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
- string-replacement-normalize is now string-replacement-focus, tying it to the replacement focusing feature it implements and dissolving the confusing two-kinds-of-normalization vocabulary - string-apply-replacement is now string-replacement-apply, joining the string-replacement-* naming family and taking the replacement first like every other operation - string-replacement-render is now string-replacement-new-text, completing the accessor family: new-span is its length and new-end is where it ends - file-apply-string-replacement! is now string-replacement-apply-to-file! Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
string-replacement-focus previously returned replacements unchanged when they didn't alter the string at all, contradicting the documented behavior. Focusing a no-op replacement now shrinks it to the smallest no-op replacement satisfying the preservation constraints: the region between preserve-start and preserve-end (clamped to the original region) with a single copied piece, degenerating to an empty replacement at the constraint position (or at the original start when no constraints are given). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Resyntax analyzed 5 files in this pull request and found no issues.
Contributor
There was a problem hiding this comment.
Resyntax analyzed 0 files in this pull request and found no issues.
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.
Continues the grimoire documentation effort (#785, #787, #789) by documenting the string replacement API — the lowest-level form that Resyntax's suggestions take before being written to files.