Skip to content

Commit

Permalink
Revert "Only show path names in Fish shell completion option list"
Browse files Browse the repository at this point in the history
This reverts commit 9b9106e.
  • Loading branch information
suzaku committed Nov 27, 2020
1 parent 235a3d4 commit c544725
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func clearNotExistDirs(entries entryList) (entryList, bool) {
func main() {
pathToAdd := flag.String("add", "", "Add this path")
complete := flag.Bool("complete", false, "Used for tab completion")
pathOnly := flag.Bool("path-only", false, "Only output path names as completion options.")
purge := flag.Bool("purge", false, "Remove non-existent paths from database")
stat := flag.Bool("stat", false, "Show information about recorded paths")
ver := flag.Bool("version", false, "Show version of shonenjump")
Expand All @@ -94,7 +93,7 @@ func main() {
} else {
arg = ""
}
showAutoCompleteOptions(arg, *pathOnly)
showAutoCompleteOptions(arg)
} else if *purge {
entries := loadEntries(dataPath)
entries, changed := clearNotExistDirs(entries)
Expand Down Expand Up @@ -150,7 +149,7 @@ func addPath(pathToAdd string) {
newEntries.Save(ensureDataPath())
}

func showAutoCompleteOptions(arg string, pathOnly bool) {
func showAutoCompleteOptions(arg string) {
needle, index, path := parseCompleteOption(arg)
if path != "" {
fmt.Println(path)
Expand All @@ -163,13 +162,8 @@ func showAutoCompleteOptions(arg string, pathOnly bool) {
entries := loadEntries(ensureDataPath())
candidates := getCandidates(entries, []string{needle}, maxCompleteOptions)
for i, path := range candidates {
if pathOnly {
fmt.Println(path)
} else {
idx := strconv.Itoa(i + 1)
output := needle + separator + idx + separator + path
fmt.Println(output)
}
parts := []string{needle, strconv.Itoa(i + 1), path}
fmt.Println(strings.Join(parts, separator))
}
}
}
2 changes: 1 addition & 1 deletion scripts/j.fish
Original file line number Diff line number Diff line change
@@ -1 +1 @@
complete -x -c j -a '(shonenjump --complete --path-only (commandline -t))'
complete -x -c j -a '(shonenjump --complete (commandline -t))'

0 comments on commit c544725

Please sign in to comment.