@@ -42,44 +42,69 @@ func ActionRawValues(currentWord string, meta common.Meta, values common.RawValu
4242 descriptionStyle = s
4343 }
4444
45+ nocolor := env .ColorDisabled ()
4546 tooltipEnabled := env .Tooltip ()
4647
4748 vals := make ([]completionResult , 0 , len (values ))
4849 for _ , val := range values {
49- if val .Value != "" { // must not be empty - any empty `''` parameter in CompletionResult causes an error
50- val . Value = sanitizer . Replace ( val . Value )
51- nospace := meta . Nospace . Matches ( val . Value )
50+ if val .Value == "" {
51+ continue // must not be empty - any empty `''` parameter in CompletionResult causes an error
52+ }
5253
53- if strings .ContainsAny (val .Value , ` {}()[]*$?\"|<>&(),;#` + "`" ) {
54- val .Value = fmt .Sprintf ("'%v'" , val .Value )
55- }
54+ val .Value = sanitizer .Replace (val .Value )
55+ nospace := meta .Nospace .Matches (val .Value )
5656
57- if ! nospace {
58- val .Value = val . Value + " "
59- }
57+ if strings . ContainsAny ( val . Value , ` {}()[]*$?\"|<>&(),;#` + "`" ) {
58+ val .Value = fmt . Sprintf ( "'%v'" , val . Value )
59+ }
6060
61- if val . Style == "" || ui . ParseStyling ( val . Style ) == nil {
62- val .Style = valueStyle
63- }
61+ if ! nospace {
62+ val .Value = val . Value + " "
63+ }
6464
65- tooltip := " "
66- if tooltipEnabled && val .Description != "" {
67- tooltip = fmt .Sprintf ("`e[%vm`e[%vm%v`e[21;22;23;24;25;29;39;49m" , sgr (descriptionStyle + " bg-default" ), sgr (descriptionStyle ), sanitizer .Replace (val .TrimmedDescription ()))
68- val .Description = ""
65+ if val .Style == "" || ui .ParseStyling (val .Style ) == nil {
66+ val .Style = valueStyle
67+ }
68+
69+ tooltip := " "
70+ if tooltipEnabled && val .Description != "" {
71+ switch nocolor {
72+ case true :
73+ tooltip = sanitizer .Replace (val .TrimmedDescription ())
74+ default :
75+ tooltip = fmt .Sprintf ("`e[%vm`e[%vm%v`e[21;22;23;24;25;29;39;49m" ,
76+ sgr (descriptionStyle + " bg-default" ),
77+ sgr (descriptionStyle ),
78+ sanitizer .Replace (val .TrimmedDescription ()))
6979 }
80+ val .Description = ""
81+ }
7082
71- listItemText := fmt .Sprintf ("`e[21;22;23;24;25;29m`e[%vm%v`e[21;22;23;24;25;29;39;49m" , sgr (val .Style ), sanitizer .Replace (val .Display ))
83+ var listItemText string
84+ switch nocolor {
85+ case true :
86+ listItemText = sanitizer .Replace (val .Display )
87+ if val .Description != "" {
88+ listItemText = fmt .Sprintf ("%v (%v)" , listItemText , sanitizer .Replace (val .TrimmedDescription ()))
89+ }
90+ default :
91+ listItemText = fmt .Sprintf ("`e[21;22;23;24;25;29m`e[%vm%v`e[21;22;23;24;25;29;39;49m" ,
92+ sgr (val .Style ),
93+ sanitizer .Replace (val .Display ))
7294 if val .Description != "" {
73- listItemText = listItemText + fmt .Sprintf ("`e[%vm `e[%vm(%v)`e[21;22;23;24;25;29;39;49m" , sgr (descriptionStyle + " bg-default" ), sgr (descriptionStyle ), sanitizer .Replace (val .TrimmedDescription ()))
95+ listItemText = listItemText + fmt .Sprintf ("`e[%vm `e[%vm(%v)`e[21;22;23;24;25;29;39;49m" ,
96+ sgr (descriptionStyle + " bg-default" ),
97+ sgr (descriptionStyle ),
98+ sanitizer .Replace (val .TrimmedDescription ()))
7499 }
75100 listItemText = listItemText + "`e[0m"
76-
77- vals = append (vals , completionResult {
78- CompletionText : val .Value ,
79- ListItemText : ensureNotEmpty (listItemText ),
80- ToolTip : ensureNotEmpty (tooltip ),
81- })
82101 }
102+
103+ vals = append (vals , completionResult {
104+ CompletionText : val .Value ,
105+ ListItemText : ensureNotEmpty (listItemText ),
106+ ToolTip : ensureNotEmpty (tooltip ),
107+ })
83108 }
84109 m , _ := json .Marshal (vals )
85110 return string (m )
0 commit comments