Fix completion, support directory open mode
This commit is contained in:
parent
57baab8251
commit
5c2a9513a4
@ -110,12 +110,17 @@ func openEditor(editor string, path string) {
|
|||||||
func getEntrypointFile(projectPath string) string {
|
func getEntrypointFile(projectPath string) string {
|
||||||
if err := os.Chdir(projectPath); err != nil {
|
if err := os.Chdir(projectPath); err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
} else if conf.Editor.OpenDirectory {
|
||||||
|
return projectPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search list of well-known main files
|
||||||
for _, f := range entrypointFiles {
|
for _, f := range entrypointFiles {
|
||||||
if _, err := os.Stat(f); err == nil {
|
if _, err := os.Stat(f); err == nil {
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import "github.com/spf13/cobra"
|
|||||||
|
|
||||||
func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||||
[]string, cobra.ShellCompDirective) {
|
[]string, cobra.ShellCompDirective) {
|
||||||
|
initProjectCache(cmd, args)
|
||||||
return cache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
return cache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,10 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type editorConfig struct {
|
type editorConfig struct {
|
||||||
DisplayName string `yaml:"displanName" json:"displanName"`
|
DisplayName string `yaml:"displanName" json:"displanName"`
|
||||||
Binary string `yaml:"binary" json:"binary"`
|
Binary string `yaml:"binary" json:"binary"`
|
||||||
OpenFlags string `yaml:"openFlags" json:"openFlags"`
|
OpenFlags string `yaml:"openFlags" json:"openFlags"`
|
||||||
|
OpenDirectory bool `yaml:"openDirectory" json:"openDirectory" description:"Don't open well-known files, open directory"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type loadConfig struct {
|
type loadConfig struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user