Skip to content

Commit

Permalink
Merge pull request #233 from rsteube/elvish-readd-linebreak-filter
Browse files Browse the repository at this point in the history
elvish: readd linebreak filtering
  • Loading branch information
rsteube authored Jan 22, 2021
2 parents 737ce72 + 9b21d4e commit 59f6159
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/elvish/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@ package elvish
import (
"encoding/json"
"fmt"
"strings"

"github.com/rsteube/carapace/internal/common"
)

var sanitizer = strings.NewReplacer(
"\n", ``,
"\r", ``,
)

func sanitize(values []common.RawValue) []common.RawValue {
for index, v := range values {
(&values[index]).Value = sanitizer.Replace(v.Value)
(&values[index]).Display = sanitizer.Replace(v.Display)
(&values[index]).Description = sanitizer.Replace(v.Description)
}
return values
}

type complexCandidate struct {
Value string
Display string
}

func ActionRawValues(callbackValue string, values ...common.RawValue) string {
vals := make([]complexCandidate, len(values))
for index, val := range values {
for index, val := range sanitize(values) {
// TODO have a look at this again later: seems elvish does a good job quoting any problematic characterS so the sanitize step was removed
if val.Description == "" {
vals[index] = complexCandidate{Value: val.Value, Display: val.Display}
Expand Down

0 comments on commit 59f6159

Please sign in to comment.