psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.83k stars 2.45k forks source link

vim plugin: After formatting editor jumps to first line #1035

Open im-n1 opened 5 years ago

im-n1 commented 5 years ago

When I run formatting once whole file gets formatted the cursor jumps to first line. Additionally all folds get closed. This is very annoying when you edit multi-thousand line file with folds almost on every second line. Even "jump back" or "got to the last edited position" doesn't work.

I get that once file is formatted line numbers change but you can still try to jump to the last one. Big updates are done only once when file is formatted for the first time. Then it's just "local" updates so lines doesn't change much. It's much better to jump from line 245 to 250 than 1.

I use vim plugin.

Rayzeq commented 1 year ago

I have a similar issue on Sublime Text using pylsp. When I run the autoformat, folded regions are moved (see screenshot). Note that only the regions that are above the formatted code are moved. image image

JelleZijlstra commented 1 year ago

This issue should only be about the vim plugin maintained in this repo. For issues with other integrations, please open an issue with your editor or plugin that provides Black formatting.

Rayzeq commented 1 year ago

Ok sorry I thought that it was global to Black