#!stacks
"sigpanic" && "server.(*server).DidCreateFiles:+20"

Issue created by stacks.

// NewFile returns a document change to complete an empty go file.
func NewFile(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) (*protocol.DocumentChange, error) {
    if bs, err := fh.Content(); err != nil || len(bs) != 0 {
        return nil, err <----------- may return no result and no error
    }
    meta, err := snapshot.NarrowestMetadataForFile(ctx, fh.URI())
    if err != nil {
        return nil, err
    }

@xieyuschen

This stack WhZjCw was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 vscode (2)
golang.org/x/tools/gopls@v0.19.0-pre.1 go1.24.3 darwin/arm64 other (9)
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 other (1)

Dups: 6JFvKA

Comment From: adonovan

Let's cherrypick a fix for this into rc3.

Comment From: adonovan

This stack 6JFvKA was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 linux/amd64 vscode (1)
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/amd64 vscode-insiders (1)
golang.org/x/tools/gopls@v0.19.0-pre.1 go1.24.3 linux/amd64 vscode (1)

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gopherbot

Change https://go.dev/cl/680259 mentions this issue: gopls/internal/golang/completion: return error if file is not new