Skip to content
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

:Prettier make cursor history wrong when navigating with <C-O> #48

Closed
trungdq88 opened this issue Aug 25, 2017 · 8 comments · Fixed by #50
Closed

:Prettier make cursor history wrong when navigating with <C-O> #48

trungdq88 opened this issue Aug 25, 2017 · 8 comments · Fixed by #50

Comments

@trungdq88
Copy link

trungdq88 commented Aug 25, 2017

After I run :Prettier, and then press <C-o> to navigate to the last position of cursor, it always point to the beginning of the file. It's annoying. Please fix this.

@mitermayer
Copy link
Member

Hi @trungdq88 thanks for reporting this issue.

Will investigate this soon, otherwise feel free to submit a PR.

@trungdq88
Copy link
Author

I wish I could, but I have no knowledge of vim script :(

@mitermayer
Copy link
Member

I tested this issue with other similar formatting plugins and they all have similar problems. :( In the meantime will merge a PR that will at least mitigate this issue.

You will still have to do the 2 times but the first time it wont take you to the top of the file (as the current described behavior) it will instead keep you on the same place.

@mitermayer
Copy link
Member

mitermayer commented Aug 30, 2017

@trungdq88 closed this issue since at this stage I am not sure that I can edit vim jump history to delete the duplicate same line entry.

I did however merge a PR that at least makes sure that when doing a <C-O> you do not jump to the beginning of the file anymore

@trungdq88
Copy link
Author

That's good enough for me 👍 Thanks a lot!

@mortyccp
Copy link

FYI: vim-go has format but it keeps the cursor position and history. You might take a look on how it achieves that.

@mitermayer
Copy link
Member

@mortyccp great finding!

managed to find where they achieve that:

https://github.com/fatih/vim-go/blob/86834ce79a00325d15a27f74733980d98ef06ad7/autoload/go/asmfmt.vim#L40

and on

https://github.com/fatih/vim-go/blob/5730b71ea57c3db0972968889a1d098139cb6031/autoload/go/fmt.vim#L53

Are examples of them deleting history, if you want to send a PR to vim-prettier you just need to adapt that similar logic to: https://github.com/prettier/vim-prettier/blob/master/autoload/prettier.vim#L176

Otherwise will see if I can squeeze sometime in to do that over the weekend

@mortyccp
Copy link

@mitermayer Sorry, I am not familiar with VimL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants