elpy
elpy copied to clipboard
elpy-black-fix-code recenters window to put cursor on bottom line
Summary
When running elpy-black-fix-code
, the window always seems to get recentered to make the cursor on the bottom line. This occurs even if the change effected by black
doesn't involve adding or removing lines to the buffer. This is particularly cumbersome if elpy-black-fix-code
is added to before-save-hook
, since it causes one to lose one's position in the buffer temporarily after every save.
Steps to reproduce
Create a buffer with enough lines to fill the window:
Center the window on some line that is roughly in the middle:
Add some trivial formatting change that will get fixed by elpy-black-fix-code
(like inserting a space):
Run elpy-black-fix-code
, in addition to the expected reformatting, the window gets recentered to put the cursor at the bottom:
I've noticed that it centers the cursor (keeping it on the same line it was on) as if it were using recenter-top-bottom
(bound to C-l
by default) to center the buffer vertically in the window. I think perhaps it's going to the "bottom" for you because the buffer isn't more than a screenful. That said, I do think the jump is jarring and (I hope) unneeded.
Can you post elpy-config
?
We have some tests failing only for specific python versions. wondering if its related to that