Skip to content

Commit

Permalink
Merge pull request #1406 from rsteube/go-mod-relative-path
Browse files Browse the repository at this point in the history
go: mod edit - support replace with relative path
  • Loading branch information
rsteube authored Nov 6, 2022
2 parents a0af0eb + 0a97737 commit 8093786
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions completers/go_completer/cmd/mod_edit.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package cmd

import (
"path/filepath"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/golang"
"github.com/rsteube/carapace-bin/pkg/util"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -40,6 +43,13 @@ func init() {
case 0:
return golang.ActionModules(golang.ModuleOpts{Direct: true, Indirect: true})
case 1:
if util.HasPathPrefix(c.CallbackValue) {
path, err := util.FindReverse(c.Dir, "go.mod")
if err != nil {
return carapace.ActionMessage(err.Error())
}
return carapace.ActionFiles().Chdir(filepath.Dir(path))
}
return golang.ActionModuleSearch()
default:
return carapace.ActionValues()
Expand Down

0 comments on commit 8093786

Please sign in to comment.