Cursor jumping on save in vscode
jesseduffield opened this issue · comments
Not sure if this is expected behaviour or not: on vscode with the following in my settings:
"emeraldwalk.runonsave": {
"commands": [
{
"match": ".*\\.go",
"cmd": "golines ${file} -w --base-formatter=gofumpt -m 120"
}
]
},
my cursor is jumping upon pressing save and running golines. It jumps to the beginning of the line following the changes, for example:
before:
func (self *ReflogCommitLoader) GetReflogCommits(lastReflogCommit *models.Commit, filterPath string) ([]*models.Commit, bool, error)<cursor> {
commits := make([]*models.Commit, 0)
after:
func (self *ReflogCommitLoader) GetReflogCommits(
lastReflogCommit *models.Commit,
filterPath string,
) ([]*models.Commit, bool, error) {
<cursor> commits := make([]*models.Commit, 0)
I expected the cursor to remain on the same character as it was before, even if that character moves.
Is this expected behaviour? If not, is it possible to get around this problem? Thanks :)
I don't know anything about VSCode, but this sort of thing is common in Vim when formatting is run over loaded buffers. Most plugins also jump, but some do gymnastics to keep the cursor where it began.
In any case, my guess is that you can't solve this from the golines
side. You'd probably have to do something to adjust VSCode itself.