Skip to content

Commit

Permalink
elvish: fix flag usage
Browse files Browse the repository at this point in the history
needed replacer for special characters
  • Loading branch information
rsteube committed Apr 18, 2020
1 parent bf34ad8 commit 126a05c
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 126a05c

Please sign in to comment.