#!stacks
"bug.Reportf" && "completion.(*completer).selector:+57"

Issue created by stacks.

    // -- completion of symbols in unimported packages --

    // use new code for unimported completions, if flag allows it
    if c.snapshot.Options().ImportsSource == settings.ImportsSourceGopls {
        // The user might have typed strings.TLower, so id.Name==strings, sel.Sel.Name == TLower,
        // but the cursor might be inside TLower, so adjust the prefix
        prefix := sel.Sel.Name
        if c.surrounding != nil {
            if c.surrounding.content != sel.Sel.Name {
                bug.Reportf("unexpected surrounding: %q != %q", c.surrounding.content, sel.Sel.Name)
            } else {
                prefix = sel.Sel.Name[:c.surrounding.cursor-c.surrounding.start]
            }
        }
        c.unimported(ctx, metadata.PackageName(id.Name), prefix)
        return nil

    }

Possible regression in https://go.dev/cl/667576?

This stack _bvZaw was reported by telemetry:

golang.org/x/tools/gopls@v0.20.0 go1.25.0 darwin/arm64 vscode (1)

Dups: BjtwIw 8lB0bg

Comment From: gabyhelp

Related Issues

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

Comment From: adonovan

This stack BjtwIw was reported by telemetry:

golang.org/x/tools/gopls@v0.20.0 go1.24.3 darwin/arm64 vscode,vscodium (1)

Comment From: adonovan

This stack 8lB0bg was reported by telemetry:

golang.org/x/tools/gopls@v0.20.0 go1.24.2 linux/amd64 vscode (1)