File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -526,7 +526,7 @@ def __init__(
526526
527527 # Cache for prompt_toolkit completion menu styles
528528 self ._cached_pt_style : PtStyle | None = None
529- self ._cached_pt_style_params : tuple [Style | None , Style | None ] | None = None
529+ self ._cached_pt_style_params : tuple [StyleType , StyleType ] | None = None
530530
531531 # Create the main PromptSession
532532 self .bottom_toolbar = bottom_toolbar
@@ -724,8 +724,8 @@ def _should_continue_multiline(self) -> bool:
724724 def _get_pt_style (self ) -> "PtStyle" :
725725 """Return the prompt_toolkit style for the completion menu."""
726726 theme = ru .get_theme ()
727- rich_item_style = theme .styles .get (Cmd2Style .COMPLETION_MENU_ITEM )
728- rich_meta_style = theme .styles .get (Cmd2Style .COMPLETION_MENU_META )
727+ rich_item_style = theme .styles .get (Cmd2Style .COMPLETION_MENU_ITEM , "" )
728+ rich_meta_style = theme .styles .get (Cmd2Style .COMPLETION_MENU_META , "" )
729729
730730 current_params = (rich_item_style , rich_meta_style )
731731 if self ._cached_pt_style is not None and self ._cached_pt_style_params == current_params :
Original file line number Diff line number Diff line change 2020from prompt_toolkit .formatted_text import ANSI
2121from prompt_toolkit .history import History
2222from prompt_toolkit .lexers import Lexer
23- from rich .style import Style
23+ from rich .style import Style , StyleType
2424
2525from . import (
2626 constants ,
@@ -88,10 +88,14 @@ def rich_to_pt_color(color: "Color | None") -> str:
8888 return f"#{ c .red :02x} { c .green :02x} { c .blue :02x} "
8989
9090
91- def rich_to_pt_style (rich_style : Style | None ) -> str :
91+ def rich_to_pt_style (rich_style : StyleType ) -> str :
9292 """Convert a rich Style object to a prompt_toolkit style string."""
9393 if not rich_style :
9494 return ""
95+
96+ if isinstance (rich_style , str ):
97+ rich_style = Style .parse (rich_style )
98+
9599 parts = ["noreverse" ]
96100
97101 fg_color = rich_to_pt_color (rich_style .color )
You can’t perform that action at this time.
0 commit comments