Skip to content

Commit

Permalink
Merge pull request #859 from rsteube/multipartsp-contest
Browse files Browse the repository at this point in the history
MultiPartsP: remove context
  • Loading branch information
rsteube committed Jul 29, 2023
2 parents 45fb542 + fc6f5d7 commit c59c323
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (a Action) MultiParts(dividers ...string) Action {
}

// MultiPartsP is like MultiParts but with placeholder completion.
func (a Action) MultiPartsP(delimiter string, placeholderPattern string, f func(segment string, matches map[string]string, c Context) Action) Action {
func (a Action) MultiPartsP(delimiter string, placeholderPattern string, f func(segment string, matches map[string]string) Action) Action {
return ActionCallback(func(c Context) Action {
invoked := a.Invoke(c)

Expand Down Expand Up @@ -171,7 +171,7 @@ func (a Action) MultiPartsP(delimiter string, placeholderPattern string, f func(
actions := make([]Action, 0, len(matchedSegments))
for key, value := range matchedSegments {
if placeholder.MatchString(key) {
actions = append(actions, f(key, matchedData, c))
actions = append(actions, f(key, matchedData))
} else {
actions = append(actions, ActionStyledValuesDescribed(key, value.Description, value.Style)) // TODO tag,..
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/carapace/action/multiPartsP.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ carapace.ActionStyledValuesDescribed(
"styles/<style>", "details", style.Default,
"styles/custom", "custom style", style.Of(style.Blue, style.Blink),
"styles", "list", style.Yellow,
).MultiPartsP("/", "<.*>", func(segment string, matches map[string]string, c carapace.Context) carapace.Action {
).MultiPartsP("/", "<.*>", func(segment string, matches map[string]string) carapace.Action {
switch segment {
case "<style>":
return carapace.ActionStyles()
Expand Down
2 changes: 1 addition & 1 deletion example/cmd/modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func init() {
"styles/<style>", "details", style.Default,
"styles/custom", "custom style", style.Of(style.Blue, style.Blink),
"styles", "list", style.Yellow,
).MultiPartsP("/", "<.*>", func(segment string, matches map[string]string, c carapace.Context) carapace.Action {
).MultiPartsP("/", "<.*>", func(segment string, matches map[string]string) carapace.Action {
switch segment {
case "<style>":
return carapace.ActionStyles()
Expand Down

0 comments on commit c59c323

Please sign in to comment.