Skip to content

Make columns indices 1-based in the text output format #539

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

Merged
merged 3 commits into from
Nov 1, 2022
Merged

Make columns indices 1-based in the text output format #539

merged 3 commits into from
Nov 1, 2022

Conversation

fsouza
Copy link
Contributor

@fsouza fsouza commented Nov 1, 2022

Not changing the column in JSON errors. Not sure if we want to change that too.

Closes #537.

Not changing the column in JSON errors. Not sure if we want to change
that too.

Closes #537.
@charliermarsh
Copy link
Member

I think it'd make sense to change it in the JSON printer too if you're up for it. Should we even consider changing it when we convert from Check to Message, so that Message is always one-indexed?

@fsouza
Copy link
Contributor Author

fsouza commented Nov 1, 2022

@charliermarsh good call! Let me make that change.

@fsouza
Copy link
Contributor Author

fsouza commented Nov 1, 2022

@charliermarsh how does this look? I originally tried to make a copy of the Location directly, but the fields are private, so I ended-up copying it and then mutating with go_right().

My Rust-fu is a bit limited here, let me know if I'm wasting your time 😁

src/message.rs Outdated
Comment on lines 23 to 26
let mut location = check.location;
location.go_right();
let mut end_location = check.end_location;
end_location.go_right();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this doesn't feel right 🙈

Copy link
Member

Choose a reason for hiding this comment

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

I think you can use Location::new and location.row() methods to create a new location here! (On subway so low-fidelity message…)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh that makes more sense hah I was too influenced by Go in my first attempt. Pushed a fix!

Copy link
Member

Choose a reason for hiding this comment

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

Woo, thanks!

@charliermarsh charliermarsh merged commit c68c6b5 into astral-sh:main Nov 1, 2022
@fsouza fsouza deleted the 1-indexed-columns-on-error-reporting branch November 1, 2022 23:06
@charliermarsh
Copy link
Member

\cc @Seamooo - we changed Message back to one-based indexing for columns. (Check still uses zero-based indexing, so if ruffd uses Check now as planned, it will be unaffected.)

@Seamooo
Copy link
Contributor

Seamooo commented Nov 3, 2022

Awesome, ruffd also now uses location and end_location in Patch and this also appears unaffected

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.

Report errors using 1-indexed columns
3 participants