Repository: rsteube/carapace
Pull request #489 (2022-04-10 00:06:20)

delimiter style


Patch:
diff --git a/internal/shell/elvish/snippet.go b/internal/shell/elvish/snippet.go
index 4727f24..af70d43 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[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
         }
     }
 }
diff --git a/internal/shell/powershell/action.go b/internal/shell/powershell/action.go
index 9cf8ebd..3315a81 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 `e[%vm(%v)`e[21;22;23;24;25;29;39;49m", sgr(descriptionStyle+" bg-default"), 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 32ddd27..b288e37 100644
--- a/internal/shell/zsh/action.go
+++ b/internal/shell/zsh/action.go
@@ -59,8 +59,8 @@ func ActionRawValues(currentWord string, nospace bool, values common.RawValues)
 			vals[index] = fmt.Sprintf("%v\t%v", val.Value, val.Display)
 			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))
+			vals[index] = fmt.Sprintf("%v\t%v%v-- %v", val.Value, val.Display, strings.Repeat(" ", maxLength-len(val.Display)+1), val.TrimmedDescription())
+			zstyles = append(zstyles, formatZstyle(fmt.Sprintf("(%v)(%v)(-- %v)", zstyleQuoter.Replace(val.Display), strings.Repeat(" ", maxLength-len(val.Display)+1), zstyleQuoter.Replace(val.TrimmedDescription())), val.Style, descriptionStyle))
 		}
 	}
 
@@ -85,5 +85,5 @@ var zstyleQuoter = strings.NewReplacer(
 // `compadd -l` (one per line) accepts ansi escape sequences in display value but it seems in tabular view these are removed.
 // To ease matching in list mode, the display values have a hidden `\002` suffix.
 func formatZstyle(s, _styleValue, _styleDescription string) string {
-	return fmt.Sprintf("=(#b)%v=0=%v=%v", s, style.SGR(_styleValue), style.SGR(_styleDescription))
+	return fmt.Sprintf("=(#b)%v=0=%v=%v=%v", s, style.SGR(_styleValue), style.SGR(_styleDescription+" bg-default"), style.SGR(_styleDescription))
 }


Test patch:
diff --git a/example/cmd/_test/elvish.elv b/example/cmd/_test/elvish.elv
index 34150cb..eea0c97 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[DescriptionStyle]" bg-default")(styled "("$c[Description]")" $c[DescriptionStyle]) &code-suffix=$c[CodeSuffix]
         }
     }
 }