fix: wrong suggestion on chmod command
This commit is contained in:
+16
-21
@@ -84,32 +84,27 @@ func FileGenerator(filters ...string) GeneratorFunc {
|
|||||||
|
|
||||||
fullPath := pathPrefix + name
|
fullPath := pathPrefix + name
|
||||||
if entry.IsDir() {
|
if entry.IsDir() {
|
||||||
results = append(results, Suggestion{
|
if dirOnly || len(filterSet) == 0 {
|
||||||
Cmd: prefix + " " + fullPath + "/",
|
results = append(results, Suggestion{
|
||||||
Desc: "directory",
|
Cmd: fullPath + "/",
|
||||||
})
|
Desc: "directory",
|
||||||
} else {
|
})
|
||||||
if dirOnly {
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// if filters are set, only show matching extensions
|
||||||
|
if len(filterSet) > 0 {
|
||||||
|
ext := strings.ToLower(filepath.Ext(name))
|
||||||
|
if !filterSet[ext] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// if filters are set, only show matching extensions
|
|
||||||
if len(filterSet) > 0 {
|
|
||||||
ext := strings.ToLower(filepath.Ext(name))
|
|
||||||
if !filterSet[ext] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results = append(results, Suggestion{
|
|
||||||
Cmd: prefix + " " + fullPath,
|
|
||||||
Desc: fileDesc(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
results = append(results, Suggestion{
|
||||||
|
Cmd: fullPath,
|
||||||
|
Desc: "file",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileDesc() string {
|
|
||||||
return "file"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -179,10 +179,7 @@ func Lookup(input string) []Suggestion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
finalCmd := g.Cmd
|
finalCmd := g.Cmd
|
||||||
cleanLinePrefix := strings.TrimSpace(linePrefix)
|
finalCmd = strings.TrimSpace(linePrefix) + " " + g.Cmd
|
||||||
if cleanLinePrefix != "" && !strings.HasPrefix(finalCmd, cleanLinePrefix) && !strings.HasPrefix(finalCmd, rootCmdName) {
|
|
||||||
finalCmd = cleanLinePrefix + " " + g.Cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
newTokens := tokenize(finalCmd)
|
newTokens := tokenize(finalCmd)
|
||||||
if len(newTokens) > 0 {
|
if len(newTokens) > 0 {
|
||||||
|
|||||||
+5
-1
@@ -380,7 +380,11 @@ func runWrapper() {
|
|||||||
ptmx.Write([]byte{0x15}) // ctrl+u to clear line
|
ptmx.Write([]byte{0x15}) // ctrl+u to clear line
|
||||||
ptmx.Write([]byte(selected))
|
ptmx.Write([]byte(selected))
|
||||||
|
|
||||||
shouldOverlayDraw = false
|
overlay.Cursor = 0 // this prevents when you tab, it switchs between suggestions non-stop
|
||||||
|
|
||||||
|
shouldOverlayDraw = true // <- rerender after tab to choose, if you set to false,
|
||||||
|
// when you press tab continuely, it will print all folder from menu suggestions
|
||||||
|
// and make the cursor jump to next line
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user