beerose / go-group-imports-vscode

VSCode extension for separating imports in go files into three groups: stdlib, 3rd party, own.
https://marketplace.visualstudio.com/items?itemName=aleksandra.go-group-imports
MIT License
31 stars 20 forks source link

Edited file is shacking on save #12

Open vorotech opened 3 years ago

vorotech commented 3 years ago

Hello, I'm reporting some weird bug When I save some files they are "shaking" infinitely until I click another file in the VSCode Explorer. And it should be a "valid file" (whatever it means, because I cannot identify the pattern) If some "invalid file" was selected the shaking continues there.

NOTE: Issue isn't reproduced when set "groupImports.onSave": false in settings and run Group commands on demand.

Check this screencast (slowed 10x times) ezgif-3-e7fa31ef0c92

The file source in the screencast:

package middleware

import (
    "github.com/gin-contrib/cors"
    "github.com/gin-gonic/gin"
)

func Cors() gin.HandlerFunc {
    corscfg := cors.DefaultConfig()
    corscfg.AllowAllOrigins = true
    corscfg.AddExposeHeaders("X-Total-Count")
    return cors.New(corscfg)
}

Extension versions where the bug reproduced:

OS: 29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021

VS Code: Version: 1.60.0 Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff Date: 2021-09-01T10:43:02.136Z Electron: 13.1.8 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Linux x64 5.11.0-27-generic snap

VS Code User Settings:

$ cat $HOME/.config/Code/User/settings.json
{
    "workbench.colorTheme": "SynthWave '84",
    "explorer.confirmDragAndDrop": false,
    "go.toolsManagement.autoUpdate": true
}

VS Code installed extensions:

$ code --list-extensions
aleksandra.go-group-imports
golang.go
ms-azuretools.vscode-docker
RobbOwen.synthwave-vscode
beerose commented 3 years ago

Hey @vorotech,

Thanks for reporting this issue! I wasn't able to reproduce it yet (worked fine with the same settings as yours, and with your example), but will try a few more things and get back to you.

1.0.1 and below has another not-related issue File is not in the gopath.

This error occurs because the previous version didn't have support for go modules and was relying on gopath.