-
Notifications
You must be signed in to change notification settings - Fork 5
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
Wrong buffer used when formating file opened in multiple views #66
Comments
How can I reproduce this? |
I'm on Ubuntu 18.04 with Sublime Text 3176. |
Do you mean you're using the command named Also which version of GoSublime are you using and what are your GoSublime ( |
It happens with both For the syntax, I'm using Here for my margo.go settings package margo
import (
"time"
"margo.sh/golang"
"margo.sh/mg"
)
// Margo is the entry-point to margo
func Margo(ma mg.Args) {
// add our reducers (margo plugins) to the store
// they are run in the specified order
// and should ideally not block for more than a couple milliseconds
ma.Use(
mg.NewReducer(func(mx *mg.Ctx) *mg.State {
// By default, events (e.g. ViewSaved) are triggered in all files.
// Replace `mg.AllLangs` with `mg.Go` to restrict events to Go(-lang) files.
// Please note, however, that this mode is not tested
// and saving a non-go file will not trigger linters, etc. for that go pkg
return mx.SetConfig(mx.Config.EnabledForLangs(
mg.Go,
))
}),
// add the day and time to the status bar
&DayTimeStatus{},
// Add `go` command integration
// this adds a new commands:
// gs: these commands are all callable through 9o:
// * go: Wrapper around the go command, adding linter support
// * go.play: Automatically build and run go commands or run go test for packages
// with support for linting and unsaved files
// * go.replay: Wrapper around go.play limited to a single instance
// by default this command is bound to ctrl+.,ctrl+r or cmd+.,cmd+r
//
// UserCmds are also added for `Go Play` and `Go RePlay`
&golang.GoCmd{},
// both GoFmt and GoImports will automatically disable the GoSublime version
// you will need to install the `goimports` tool manually
// https://godoc.org/golang.org/x/tools/cmd/goimports
//
// golang.GoFmt,
// or
golang.GoImports,
// show func arguments/calltips in the status bar
// gs: this replaces the `calltips` setting
&golang.GocodeCalltips{},
&golang.Guru{},
// use gocode for autocompletion
&golang.Gocode{
// automatically install missing packages
Autobuild: true,
// autocompete packages that are not yet imported
// this goes well with GoImports
UnimportedPackages: true,
// show the function parameters. this can take up a lot of space
ShowFuncParams: true,
},
// add some default context aware-ish snippets
golang.Snippets,
// add our own snippets
// check the file for syntax errors
&golang.SyntaxCheck{},
// add our own snippets
MySnippets,
// run `go install` on save
// or use GoInstallDiscardBinaries which will additionally set $GOBIN
// to a temp directory so binaries are not installed into your $PATH
//
golang.GoInstall("-i"),
// or
// golang.GoInstallDiscardBinaries(),
// run `go vet` on save. go vet is ran automatically as part of `go test` in go1.10
golang.GoVet(),
// run `go test -race` on save
// in go1.10, go vet is ran automatically
golang.GoTest("-race"),
// run `golint` on save
// &golang.Linter{Name: "golint", Label: "Go/Lint"},
// run gometalinter on save
&golang.Linter{Name: "gometalinter", Args: []string{
"--disable=gas",
"--fast",
}},
)
}
// DayTimeStatus adds the current day and time to the status bar
type DayTimeStatus struct {
mg.ReducerType
}
func (dts DayTimeStatus) ReducerMount(mx *mg.Ctx) {
// kick off the ticker when we start
dispatch := mx.Store.Dispatch
go func() {
ticker := time.NewTicker(1 * time.Second)
for range ticker.C {
dispatch(mg.Render)
}
}()
}
func (dts DayTimeStatus) Reduce(mx *mg.Ctx) *mg.State {
// we always want to render the time
// otherwise it will sometimes disappear from the status bar
now := time.Now()
format := "Mon, 15:04"
if now.Second()%2 == 0 {
format = "Mon, 15 04"
}
return mx.AddStatus(now.Format(format))
}
// MySnippets is a slice of functions returning our own snippets
var MySnippets = golang.SnippetFuncs(
func(cx *golang.CompletionCtx) []mg.Completion {
// if we're not in a block (i.e. function), do nothing
if !cx.Scope.Is(golang.BlockScope) {
return nil
}
return []mg.Completion{
{
Query: "if err",
Title: "err != nil { return }",
Src: "if ${1:err} != nil {\n\treturn $0\n}",
},
}
},
) |
Are you able to make a screen recording of the bug? I can't reproduce it and I don't have any clues how it could happen. Anything I do in one view is always replicated in the other so maybe I miss-understand the issue. Does it happen if you press ctrl+.,ctrl+f? maybe there's a race condition of some kind when saving. Also what version of GoSublime are you using? |
I tried reproducing, It happened on my company project (which I can't record for closed source reasons), tried the same on a random project where it didn't reproduce. When I got back to my company project everything worked fine and it was fixed. Usually when this bug happen I close all similar files and reopen them and it work again. Maybe it's a bad plugin combo or a bad configuration in my project settings. I'm using Gosublime 18.10.06 I will continue to try and send you a video of this bug happening |
Another thing to try is disabling
No problem :) |
Commenting those line correctly disable the auto formatting. |
BTW, you can send stuff to support at margo.sh if you don't want to upload to the public issue tracker. |
When a file is opened multiples times in split screen it sometimes happen that when saving the wrong buffer is used for the format step with gofmt, resulting in a rollback in your modification.
The text was updated successfully, but these errors were encountered: