9fans / acme-lsp

Language Server Protocol tools for the acme text editor
MIT License
193 stars 25 forks source link

formatOnPut behaving erratically #33

Closed mpl closed 4 years ago

mpl commented 4 years ago

As it is difficult to explain the behavior, and I do not have reliable instruction for a repro yet, here is a video demonstrating the behavior for now:

https://granivo.re/tmp/acme_lsp_fmt-2020-02-28_10.45.46.mov

One systematic aspect of the bug though, is the file(s) for which it happens: i.e. I haven't been able to make it not happen for a file where I observe the buggy behavior, and vice-versa.

acme-lsp: c143b86e62204682c98e5e3cd8c7e2cea8ab234e golang.org/x/tools/gopls v0.3.2 h1:eP1aj1AvT6ynElQH6KP0mmOT2gnWa1gYclHL4wGUbMo=

As requested by @fhs , I will provide the gopls rpc trace when I have it.

fhs commented 4 years ago

I haven't been able to reproduce the issue. I'm running acme-lsp like this, which outputs the RPC trace to stderr:

acme-lsp -v -workspaces /tmp/issue33 -server '\.go$:gopls serve -rpc.trace'

The code:

$ cat /tmp/issue33/go.mod 
module example.com/issue33

go 1.14
$ cat /tmp/issue33/main.go 
package main

import (
    "flag"
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
)

func main() {
    var port = flag.Int("port", 8888, "port to listen on")
    var shutup = flag.Bool("shutup", false, "shutup")
    flag.Parse()

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        if *shutup {
            return
        }
        body, err := ioutil.ReadAll(r.Body)
        if err != nil {
            log.Println(err.Error())
            fmt.Fprintf(w, "BACKEND ERROR")
            return
        }
        w.WriteHeader(200)
    })
    log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
}

acme-lsp and gopls version:

$ go version -m $(which acme-lsp gopls)|grep "\smod"
    mod github.com/fhs/acme-lsp v0.9.1  h1:ujOpRx9f3ubA3kCstSrV7BoyXRVE3whXjKxG0QysJ7g=
    mod golang.org/x/tools/gopls    v0.3.2  h1:eP1aj1AvT6ynElQH6KP0mmOT2gnWa1gYclHL4wGUbMo=
mpl commented 4 years ago

For some reason I cannot reproduce anymore, in what I believe to be the same circumstances. And in any case, I haven't hit any such problem again while doing actual work, so as far as I'm concerned you can feel free to close the issue for now.