diff --git a/internal/shell/elvish/action.go b/internal/shell/elvish/action.go index 3a592034c..5e8d712d8 100644 --- a/internal/shell/elvish/action.go +++ b/internal/shell/elvish/action.go @@ -36,6 +36,7 @@ type complexCandidate struct { Description string CodeSuffix string Style string + Tag string } // ActionRawValues formats values for elvish. @@ -60,7 +61,7 @@ func ActionRawValues(currentWord string, meta common.Meta, values common.RawValu if val.Style == "" || ui.ParseStyling(val.Style) == nil { val.Style = valueStyle } - vals[index] = complexCandidate{Value: val.Value, Display: val.Display, Description: val.Description, CodeSuffix: suffix, Style: val.Style} + vals[index] = complexCandidate{Value: val.Value, Display: val.Display, Description: val.Description, CodeSuffix: suffix, Style: val.Style, Tag: val.Tag} } if len(values) > 0 { diff --git a/internal/shell/elvish/snippet.go b/internal/shell/elvish/snippet.go index a06f3380a..c292fde6b 100644 --- a/internal/shell/elvish/snippet.go +++ b/internal/shell/elvish/snippet.go @@ -19,10 +19,18 @@ func Snippet(cmd *cobra.Command) string { edit:notify (styled "usage: " $completion[DescriptionStyle])$completion[Usage] } put $completion[Candidates] | all (one) | peach {|c| - if (eq $c[Description] "") { - edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix] - } else { - edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])(styled " " $completion[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $completion[DescriptionStyle]) &code-suffix=$c[CodeSuffix] + try { + if (eq $c[Description] "") { + edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix] &tag=$c[Tag] + } else { + edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])(styled " " $completion[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $completion[DescriptionStyle]) &code-suffix=$c[CodeSuffix] &tag=$c[Tag] + } + } catch { + if (eq $c[Description] "") { + edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style]) &code-suffix=$c[CodeSuffix] + } else { + edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])(styled " " $completion[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $completion[DescriptionStyle]) &code-suffix=$c[CodeSuffix] + } } } }