Repository navigation
fix: clamp the format range to the text in the editor service - #1345
Merged
Merged
Conversation
…amp-range # Conflicts: # crates/dprint/src/commands/editor/mod.rs
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.
The editor service passed the format range an editor sent straight to the plugin without checking it against the text. Plugins index into the text with the range, so a range that ended past the end of the text or started after its end could make a plugin fail (ex. panic on an out of bounds slice).
Now the range is clamped to the text when the format message is read: the end is clamped to the length of the text and the start is clamped to the end. A range that covers the whole text once clamped is treated as formatting the whole text, the same as before for an exact one.