Skip to content

API that returns the ranges modified #1173

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

Closed
nrc opened this issue Sep 27, 2016 · 3 comments
Closed

API that returns the ranges modified #1173

nrc opened this issue Sep 27, 2016 · 3 comments
Labels

Comments

@nrc
Copy link
Member

nrc commented Sep 27, 2016

This would be an altered diff mode that returns the lines modified and the new lines, rather than a standard diff. Useful for embedding in IDEs.

@jugglerchris
Copy link
Contributor

I'd like to have a go at this. It looks to me like what's needed is another function a lot like format_input(), but which instead of taking an reference to a T:Write to write the output returns something like Vec<(lineno, num_lines, Vec<String>)> in the Ok path for the lines changed. I guess the WriteMode in the config would be ignored, but it would do the same as with WriteMode::Diff except for the formatting of the result.

I don't think any visible change to the rustfmt binary is needed or makes sense (though maybe similar information returned as JSON might be useful if anything wants to run the rustfmt binary instead of using the library.

Am I thinking along the right lines?

@nrc
Copy link
Member Author

nrc commented Oct 16, 2017

Hi @jugglerchris it would be great if you could have a go at this! (I'm on parental leave right now, so will be a bit slow to respond). Ideally we would just add another write_mode, but I guess that might be difficult. If that doesn't work, then adding a new function as you suggest sounds good. It would be nice to share as much code as possible between the new function and format_input as possible since format_input is a bit complex.

@jugglerchris
Copy link
Contributor

I thought about a new write mode, but that doesn't directly help the RLS (which I understand is the motivating use case), since format_input can only return via the Option<&mut T:Write>.

I'll see if I can get something working and see how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants