Repository: rsteube/carapace
Pull request #485 (2022-04-08 18:28:17)

style: consistent highlight


Patch:
diff --git a/internal/shell/elvish/snippet.go b/internal/shell/elvish/snippet.go
index 0e3a8d1..4727f24 100644
--- a/internal/shell/elvish/snippet.go
+++ b/internal/shell/elvish/snippet.go
@@ -15,7 +15,7 @@ func Snippet(cmd *cobra.Command) string {
         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 $c[Description] $c[DescriptionStyle])")" &code-suffix=$c[CodeSuffix]
+            edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])" "(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
         }
     }
 }
diff --git a/internal/shell/powershell/action.go b/internal/shell/powershell/action.go
index 7b2de76..9cf8ebd 100644
--- a/internal/shell/powershell/action.go
+++ b/internal/shell/powershell/action.go
@@ -64,7 +64,7 @@ func ActionRawValues(currentWord string, nospace bool, values common.RawValues)
 
 			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))
 			if val.Description != "" {
-				listItemText = listItemText + fmt.Sprintf(" (`e[%vm%v`e[21;22;23;24;25;29;39;49m)", sgr(descriptionStyle), sanitizer.Replace(val.TrimmedDescription()))
+				listItemText = listItemText + fmt.Sprintf(" `e[%vm(%v)`e[21;22;23;24;25;29;39;49m", sgr(descriptionStyle), sanitizer.Replace(val.TrimmedDescription()))
 			}
 			listItemText = listItemText + "`e[0m"
 
diff --git a/internal/shell/zsh/action.go b/internal/shell/zsh/action.go
index 0fffa86..32ddd27 100644
--- a/internal/shell/zsh/action.go
+++ b/internal/shell/zsh/action.go
@@ -60,7 +60,7 @@ func ActionRawValues(currentWord string, nospace bool, values common.RawValues)
 			zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v)()", zstyleQuoter.Replace(val.Display)), val.Style, descriptionStyle))
 		} else {
 			vals[index] = fmt.Sprintf("%v\t%v %v-- %v", val.Value, val.Display, strings.Repeat(" ", maxLength-len(val.Display)), val.TrimmedDescription())
-			zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v) %v-- (%v)", zstyleQuoter.Replace(val.Display), strings.Repeat(" ", maxLength-len(val.Display)), zstyleQuoter.Replace(val.TrimmedDescription())), val.Style, descriptionStyle))
+			zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v) %v(-- %v)", zstyleQuoter.Replace(val.Display), strings.Repeat(" ", maxLength-len(val.Display)), zstyleQuoter.Replace(val.TrimmedDescription())), val.Style, descriptionStyle))
 		}
 	}
 


Test patch:
diff --git a/example/cmd/_test/elvish.elv b/example/cmd/_test/elvish.elv
index e40cc5a..34150cb 100644
--- a/example/cmd/_test/elvish.elv
+++ b/example/cmd/_test/elvish.elv
@@ -3,7 +3,7 @@ set edit:completion:arg-completer[example] = {|@arg|
         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 $c[Description] $c[DescriptionStyle])")" &code-suffix=$c[CodeSuffix]
+            edit:complex-candidate $c[Value] &display=(styled $c[Display] $c[Style])" "(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
         }
     }
 }