diff --git a/tools/build_langserver/lsp/completion.go b/tools/build_langserver/lsp/completion.go index 83bd156374..546ac536b2 100644 --- a/tools/build_langserver/lsp/completion.go +++ b/tools/build_langserver/lsp/completion.go @@ -40,7 +40,7 @@ func (h *Handler) completeLabel(doc *doc, partial string, line, col int) (*lsp.C if !strings.HasPrefix(s, partial) { s = t.Label.String() // Don't abbreviate it if we end up losing part of what's there } - list.Items = append(list.Items, completionItem(s, partial, line, col)) + list.Items = append(list.Items, completionItem(s, line, col)) m[s] = true } } @@ -51,7 +51,7 @@ func (h *Handler) completeLabel(doc *doc, partial string, line, col int) (*lsp.C for _, target := range h.allTargets(doc) { if (label.Name == "all" && !strings.HasPrefix(label.Name, "_")) || strings.HasPrefix(target, label.Name) { if s := ":" + target; !m[s] { - list.Items = append(list.Items, completionItem(s, partial, line, col)) + list.Items = append(list.Items, completionItem(s, line, col)) } } } @@ -101,7 +101,7 @@ func (h *Handler) completeString(doc *doc, s string, line, col int) (*lsp.Comple Items: make([]lsp.CompletionItem, len(matches)), } for i, match := range matches { - list.Items[i] = completionItem(match, s, line, col) + list.Items[i] = completionItem(match, line, col) } return list, nil } @@ -111,7 +111,7 @@ func (h *Handler) completeIdent(doc *doc, s string, line, col int) (*lsp.Complet list := &lsp.CompletionList{} for name, f := range h.builtins { if strings.HasPrefix(name, s) { - item := completionItem(name, s, line, col) + item := completionItem(name, line, col) item.Documentation = f.Stmt.FuncDef.Docstring item.Kind = lsp.CIKFunction list.Items = append(list.Items, item) @@ -141,13 +141,13 @@ func stringLiteral(s string) string { return s[1 : len(s)-1] } -func completionItem(label, prefix string, line, col int) lsp.CompletionItem { +func completionItem(label string, line, col int) lsp.CompletionItem { return lsp.CompletionItem{ Label: label, Kind: lsp.CIKValue, InsertTextFormat: lsp.ITFPlainText, TextEdit: &lsp.TextEdit{ - NewText: strings.TrimPrefix(label, prefix), + NewText: label, Range: lsp.Range{ Start: lsp.Position{Line: line, Character: col}, End: lsp.Position{Line: line, Character: col}, @@ -204,7 +204,7 @@ func (h *Handler) completePackages(pkg *pkg, allParts, parts []string, line, col // Last part, take anything in here with the relevant prefix for name := range pkg.Subpackages { if strings.HasPrefix(name, part) { - items = append(items, completionItem(prefix+name, prefix+part, line, col)) + items = append(items, completionItem(prefix+name, line, col)) } } } else if pkg.Subpackages != nil {