diff --git a/elvish/action.go b/elvish/action.go index ebbc03bc3..cc16e435a 100644 --- a/elvish/action.go +++ b/elvish/action.go @@ -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") diff --git a/elvish/snippet.go b/elvish/snippet.go index b4fe92d86..ad2ef2855 100644 --- a/elvish/snippet.go +++ b/elvish/snippet.go @@ -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))