vim-prettier icon indicating copy to clipboard operation
vim-prettier copied to clipboard

On format, split gets scrolled to bottom of file.

Open dyllandry opened this issue 4 years ago • 5 comments

Do you want to request a feature or report a bug? Report a bug.

What is the current/expected behavior? When a file is formatted, my split open to the same file gets scrolled to the bottom. This is pretty annoying.

What version of vim-prettier are you using - (output of :PrettierVersion) ? 1.0.0-alpha

What version of prettier are you using - (output of :PrettierCliVersion) ? 1.19.1

What is your prettier executable path - (output of :PrettierCliPath) ? /home/dylan/development/siesde/drp/node_modules/.bin/prettier

Did this work in previous versions of vim-prettier and/or prettier ? I do not know.

This happens in every file type I've tried so far, vue files and javascript files.

dyllandry avatar Jun 04 '20 15:06 dyllandry

I can reproduce it here.

really annoying.

falcucci avatar Jun 27 '20 21:06 falcucci

Has anyone found a workaround to this ? I've learned to live with it for lack of a better solution but I would love a fix.

edit: I did find a very involved workaround which ~~uses~~ blatantly steals code from prettierd including this little modification to restore the cursor position in all windows (the original version actually does work exactly like vim-prettier ...), thank you @fsouza !

pyrho avatar Jun 01 '21 12:06 pyrho

What exactly is the workaround @pyrho ? The issue is still not fixed here.

timonson avatar Jul 27 '21 13:07 timonson

Calling this function gathers all the lines from the current buffer and feeds it to prettierd via its stdin; the output from prettierd is then used to replace the current contents of the buffer by using this wrapper.

The wrapper first saves the cursor positions of the cursor (in each "window"), writes the contents of the buffer, then "moves" the cursor back to where it was (more or less, depending of the the violence of the re-formatting).

As I said it's pretty involved ...

pyrho avatar Jul 27 '21 14:07 pyrho

This is still happening for me - on vertical split, one of the windows gets scrolled to the bottom on format. Short of a fix, is there a workaround?

@pyrho other vim formatters, eg vim-go handle this without any issues so it might be worth seeing if there's anything that can be borrowed from there to make the work here easier.

j0sh avatar Jan 24 '24 19:01 j0sh