Skip to content

Commit

Permalink
Merge pull request #35 from rsteube/fix-elvish-replacer
Browse files Browse the repository at this point in the history
elvish: fix flag usage
  • Loading branch information
rsteube authored Apr 18, 2020
2 parents bf34ad8 + 126a05c commit 8c6a32b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions elvish/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ func ActionValues(values ...string) string {

func ActionValuesDescribed(values ...string) string {
// TODO verify length (description always exists)
sanitized := Sanitize(values...)
vals := make([]string, len(values))
for index, val := range values {
for index, val := range sanitized {
if index%2 == 0 {
vals[index/2] = fmt.Sprintf(`edit:complex-candidate %v &display-suffix=' (%v)'`, val, values[index+1])
vals[index/2] = fmt.Sprintf(`edit:complex-candidate %v &display-suffix=' (%v)'`, val, sanitized[index+1])
}
}
return strings.Join(vals, "\n")
Expand Down
2 changes: 1 addition & 1 deletion elvish/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func snippetPositionalCompletion(action string) string {
func snippetFlagCompletion(flag *pflag.Flag, action string) (snippet string) {
spec := []string{
fmt.Sprintf(`&long=%v`, flag.Name),
fmt.Sprintf(`&desc='%v'`, flag.Usage),
fmt.Sprintf(`&desc='%v'`, replacer.Replace(flag.Usage)),
}
if flag.Shorthand != "" {
spec = append(spec, fmt.Sprintf(`&short=%v`, flag.Shorthand))
Expand Down

0 comments on commit 8c6a32b

Please sign in to comment.