Skip to content

Commit 22dc334

Browse files
committed
powershell: leave out escape codes for NO_COLOR
1 parent 13617b4 commit 22dc334

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

internal/shell/powershell/action.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ 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))
@@ -64,15 +65,29 @@ func ActionRawValues(currentWord string, meta common.Meta, values common.RawValu
6465

6566
tooltip := " "
6667
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+
switch nocolor {
69+
case true:
70+
tooltip = sanitizer.Replace(val.TrimmedDescription())
71+
default:
72+
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()))
73+
}
6874
val.Description = ""
6975
}
7076

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))
72-
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()))
77+
var listItemText string
78+
switch nocolor {
79+
case true:
80+
listItemText = sanitizer.Replace(val.Display)
81+
if val.Description != "" {
82+
listItemText = sanitizer.Replace(val.TrimmedDescription())
83+
}
84+
default:
85+
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))
86+
if val.Description != "" {
87+
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()))
88+
}
89+
listItemText = listItemText + "`e[0m"
7490
}
75-
listItemText = listItemText + "`e[0m"
7691

7792
vals = append(vals, completionResult{
7893
CompletionText: val.Value,

0 commit comments

Comments
 (0)