Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when using Byte Spans. #107

Merged
merged 3 commits into from
Mar 28, 2024
Merged

Fix crashes when using Byte Spans. #107

merged 3 commits into from
Mar 28, 2024

Conversation

VonTum
Copy link
Contributor

@VonTum VonTum commented Mar 27, 2024

This pull request does include a breaking change, namely Source::get_line_text now returns the full line, including trailing whitespace and newline.

It also includes a new test, ensuring that no possible byte span in a small excerpt causes a crash.

This was causing crashes using byte spans when byte spans start or end in whitespace after a line. When I write the code I did not expect get_line_text to trim whitespace.

I edited uses of get_line_text to do the trimming separately.

Technically this is a breaking change.
src/write.rs Outdated
Comment on lines 1015 to 1016
for i in 0..source.len() {
for j in i..source.len() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ranges should probably be ..= here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch, is it possible to amend a PR?

@zesterer
Copy link
Owner

Thanks for the PR!

@zesterer zesterer merged commit ed66239 into zesterer:main Mar 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants