-
Notifications
You must be signed in to change notification settings - Fork 189
Fix window scrolling after rustfmt is run #269
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Works nicely for me. I'd suggest using a let binding instead of
|
@jjwest thanks, appreciated! I've pushed a patch to reflect your suggestion. |
Issue #256 looks like also related |
Isn't this is the reason that (save-excursion
(rust--format-call (current-buffer))) |
@drrlvn |
@sebastiencs I see. I tried looking at how Is there such an option in |
review @nikomatsakis? anyone? suggestions? thanks |
I think I finally found a solution. Instead of using stdin, I save the buffer, run rustfmt on the file and revert the buffer. It would be great if somebody could confirm this actually works with rustic. |
This looks like a pretty simple patch :) |
@nikomatsakis I'm sorry I had lost track of this issue :-) you mean this patch can be pushed forward? I think I've been using it since. |
Ill try to take a look at this this week. It would be interesting to try to figure out how to make a regression test for this ... |
@nikomatsakis thanks for having a look at this patch. I can verify the effect of the patch on a sample Rust source file. However I'm afraid I can't provide an elisp test because my knowledge on that is pretty limited. If anyone is willing to help, I'd be really happy to provide a test case for the regression. In any case here's how to reproduce:
With my patch step (5) does not happen Hope this helps |
@apiraino You have to install rust and rustfmt in the travis config first. Then you can start with a simple test that formats a buffer. Afterwards you can write the regression test with |
@brotzeit sorry for the long hiatus, got a lot going on. So, I did a little reseach and tried writing a test for this PR. I believe what I need to test is the I tried allocating a temporary buffer as in other tests ( Here's a gist of what I am at this moment: |
Hi @apiraino, About the test, the problem is with the
I will merge once the test is checked in. |
Hi, Any news on this ? Thank you ! |
Integrated, thanks. Sorry for the long delay! :) |
Hello,
I tried investigating the window scrolling after rustfmt is run (this issue has been referenced in various forms in issues #268 #231 #251) as I am still experiencing it and imo it's pretty annoying.
I'm not an elisp expert, but I think a quick fix/workaround could be to simply nail the window start position and restore it after rustfmt has finished.
I think there may be still cases where the code reformatting can be a bit confusing (f.e.
rustfmt
'ing a big messed up file), but at least I'm not getting mad every time I compulsively save a buffer :-)Can you let me know what you think of this little patch? I tested it a bit and it has greatly improved my coding experience with rustfmt.
Thanks for your time!
EDIT: I did some checks, but I'm not sure how to fix those warning that make the CI fail
EDIT2: maybe fixed (not sure if fix is correct though)