vim-prettier
vim-prettier copied to clipboard
On format, split gets scrolled to bottom of file.
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.
I can reproduce it here.
really annoying.
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 !
What exactly is the workaround @pyrho ? The issue is still not fixed here.
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 ...
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.