-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
using goimports for go_fmt_command moves the cursor on save #1342
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
Comments
Thanks for the feedback. I know this is annoying. Actually the cursor still says on the same line number (vim does the correct thing) but because we added/removed lines, it seems like your cursor jumped to another position. Anyway, this is fixed now in master by getting the diff of the number of lines and then adjusting the cursor position after the formatting finishes. Please pull the latest master to use it. |
That's awesome! Thanks for addressing this so quickly. I was going to take a go at it this weekend but you beat me to it :) I'm grabbing the code to test now. |
It looks like it retains the proper relative row now, but it seems like it's moving my cursor to the first column when goimports adjusts the file length (so the column position is getting lost). |
Behavior
Anytime I add or delete a line that requires adding or deleting an import, my cursor gets moved when I save the file (when adding a line, my cursor gets moved up one line from where I was; when I delete a line, the cursor gets moved down a line, because goimports has added or removed lines). It would be nice if my cursor stayed locked to the same line of code I was on already, before saving.
Steps to reproduce:
let g:go_fmt_command = "goimports"
fmt.Println("vim-go")
with the contents:user := os.Getenv("user")
u
inuser
:w
Configuration
vimrc
contains onlylet g:go_fmt_command = "goimports"
The text was updated successfully, but these errors were encountered: