From 5a9656936d83c03440e5b437421cb0fb92e62e31 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 1 Sep 2023 14:50:05 -0400 Subject: [PATCH] gopls/internal/lsp/cmd: don't use x/exp/slices A direct dependency on x/exp/slices was added in CL 497756. As a matter of policy, we don't depend on x/exp from gopls. Also, this left the module in an untidy state. I suspect that the slices package was added by a bad goimports operation, which is another issue entirely. In any case, the standard library slices package is not available in 1.18. Change-Id: I76b78313537ef9918317ecec25c4b12ed526c62f Reviewed-on: https://go-review.googlesource.com/c/tools/+/524817 gopls-CI: kokoro LUCI-TryBot-Result: Go LUCI Auto-Submit: Robert Findley Reviewed-by: Alan Donovan --- gopls/internal/lsp/cmd/cmd.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gopls/internal/lsp/cmd/cmd.go b/gopls/internal/lsp/cmd/cmd.go index 267456bc4be..340073d8a5a 100644 --- a/gopls/internal/lsp/cmd/cmd.go +++ b/gopls/internal/lsp/cmd/cmd.go @@ -21,7 +21,6 @@ import ( "text/tabwriter" "time" - "golang.org/x/exp/slices" "golang.org/x/tools/gopls/internal/lsp" "golang.org/x/tools/gopls/internal/lsp/browser" "golang.org/x/tools/gopls/internal/lsp/cache" @@ -547,13 +546,13 @@ func (c *cmdClient) ApplyEdit(ctx context.Context, p *protocol.ApplyWorkspaceEdi // files, honoring the preferred edit mode specified by cli.app.editMode. // (Used by rename and by ApplyEdit downcalls.) func (cli *cmdClient) applyWorkspaceEdit(edit *protocol.WorkspaceEdit) error { - var orderedURIs []span.URI + var orderedURIs []string edits := map[span.URI][]protocol.TextEdit{} for _, c := range edit.DocumentChanges { if c.TextDocumentEdit != nil { uri := fileURI(c.TextDocumentEdit.TextDocument.URI) edits[uri] = append(edits[uri], c.TextDocumentEdit.Edits...) - orderedURIs = append(orderedURIs, uri) + orderedURIs = append(orderedURIs, string(uri)) } if c.RenameFile != nil { return fmt.Errorf("client does not support file renaming (%s -> %s)", @@ -561,8 +560,9 @@ func (cli *cmdClient) applyWorkspaceEdit(edit *protocol.WorkspaceEdit) error { c.RenameFile.NewURI) } } - slices.Sort(orderedURIs) - for _, uri := range orderedURIs { + sort.Strings(orderedURIs) + for _, u := range orderedURIs { + uri := span.URIFromURI(u) f := cli.openFile(uri) if f.err != nil { return f.err