]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/autocomplete.go
Fix: mouse clicking with softwrap
[micro.git] / cmd / micro / autocomplete.go
index 9d4ceab46a86f6bd0e6cd0d60745956363a2e338..47aeca7344821599c1eeec04dceec401aa3bcb44 100644 (file)
@@ -84,9 +84,9 @@ func CommandComplete(input string) (string, []string) {
 func HelpComplete(input string) (string, []string) {
        var suggestions []string
 
-       for _, topic := range helpFiles {
+       for _, file := range ListRuntimeFiles(RTHelp) {
+               topic := file.Name()
                if strings.HasPrefix(topic, input) {
-
                        suggestions = append(suggestions, topic)
                }
        }
@@ -149,3 +149,29 @@ func PluginComplete(complete Completion, input string) (chosen string, suggestio
        }
        return
 }
+
+func PluginCmdComplete(input string) (chosen string, suggestions []string) {
+       for _, cmd := range []string{"install", "remove", "search", "update", "list"} {
+               if strings.HasPrefix(cmd, input) {
+                       suggestions = append(suggestions, cmd)
+               }
+       }
+
+       if len(suggestions) == 1 {
+               chosen = suggestions[0]
+       }
+       return chosen, suggestions
+}
+
+func PluginNameComplete(input string) (chosen string, suggestions []string) {
+       for _, pp := range GetAllPluginPackages() {
+               if strings.HasPrefix(pp.Name, input) {
+                       suggestions = append(suggestions, pp.Name)
+               }
+       }
+
+       if len(suggestions) == 1 {
+               chosen = suggestions[0]
+       }
+       return chosen, suggestions
+}