From 5c2a9513a40b0a60caf2402b2f5fe0d6df152461 Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Fri, 29 Dec 2023 08:55:06 -0500 Subject: [PATCH] Fix completion, support directory open mode --- cmd/project_open.go | 5 +++++ cmd/util_completion.go | 1 + internal/config/config.go | 7 ++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/project_open.go b/cmd/project_open.go index 6980a8e..0053972 100644 --- a/cmd/project_open.go +++ b/cmd/project_open.go @@ -110,12 +110,17 @@ func openEditor(editor string, path string) { func getEntrypointFile(projectPath string) string { if err := os.Chdir(projectPath); err != nil { return "" + } else if conf.Editor.OpenDirectory { + return projectPath } + + // Search list of well-known main files for _, f := range entrypointFiles { if _, err := os.Stat(f); err == nil { return f } } + return "" } diff --git a/cmd/util_completion.go b/cmd/util_completion.go index 74f0f74..cf8aeac 100644 --- a/cmd/util_completion.go +++ b/cmd/util_completion.go @@ -4,6 +4,7 @@ import "github.com/spf13/cobra" func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) ( []string, cobra.ShellCompDirective) { + initProjectCache(cmd, args) return cache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp } diff --git a/internal/config/config.go b/internal/config/config.go index 27c14c3..0d4255d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,9 +15,10 @@ type Config struct { } type editorConfig struct { - DisplayName string `yaml:"displanName" json:"displanName"` - Binary string `yaml:"binary" json:"binary"` - OpenFlags string `yaml:"openFlags" json:"openFlags"` + DisplayName string `yaml:"displanName" json:"displanName"` + Binary string `yaml:"binary" json:"binary"` + OpenFlags string `yaml:"openFlags" json:"openFlags"` + OpenDirectory bool `yaml:"openDirectory" json:"openDirectory" description:"Don't open well-known files, open directory"` } type loadConfig struct {