From bff1b3de9c690d201a1f972ff56c77e9dba5dffd Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 27 Sep 2024 19:43:12 -0700 Subject: [PATCH] refactor: centralize completion menu styles in _get_style method to reduce code duplication --- aider/io.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/aider/io.py b/aider/io.py index a26c2fa72..5069c9334 100644 --- a/aider/io.py +++ b/aider/io.py @@ -257,6 +257,13 @@ class InputOutput: style_dict = {"": self.user_input_color} else: style_dict.setdefault("", self.user_input_color) + # Add the completion menu styles + style_dict.update({ + "completion-menu": f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}", + "completion-menu.completion.current": ( + f"bg:{self.completion_menu_current_bg_color} {self.completion_menu_current_color}" + ), + }) return Style.from_dict(style_dict) else: return None @@ -340,10 +347,6 @@ class InputOutput: style_dict = { "pygments.literal.string": f"bold italic {self.user_input_color}", - "completion-menu": f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}", - "completion-menu.completion.current": ( - f"bg:{self.completion_menu_current_bg_color} {self.completion_menu_current_color}" - ), } style = self._get_style(style_dict) @@ -485,13 +488,7 @@ class InputOutput: else: self.tool_output(subject, bold=True) - style_dict = { - "completion-menu": f"bg:{self.completion_menu_bg_color} {self.completion_menu_color}", - "completion-menu.completion.current": ( - f"bg:{self.completion_menu_current_bg_color} {self.completion_menu_current_color}" - ), - } - style = self._get_style(style_dict) + style = self._get_style() if style is None: style = {}