package xonsh
import (
"encoding/json"
"fmt"
"strings"
"github.com/rsteube/carapace/internal/common"
)
var sanitizer = strings .NewReplacer (
"\n" , `` ,
"\t" , `` ,
`'` , `\'` ,
)
type richCompletion struct {
Value string
Display string
Description string
}
func ActionRawValues (currentWord string , meta common .Meta , values common .RawValues ) string {
vals := make ([]richCompletion , len (values ))
for index , val := range values {
val .Value = sanitizer .Replace (val .Value )
if strings .ContainsAny (val .Value , ` ()[]{}*$?\"|<>&;#` +"`" ) {
if strings .Contains (val .Value , `\` ) {
val .Value = fmt .Sprintf ("r'%v'" , val .Value )
} else {
val .Value = fmt .Sprintf ("'%v'" , val .Value )
}
}
if !meta .Nospace .Matches (val .Value ) {
val .Value = val .Value + " "
}
vals [index ] = richCompletion {Value : val .Value , Display : val .Display , Description : val .TrimmedDescription ()}
}
m , _ := json .Marshal (vals )
return string (m )
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .