From 5db92459eeab0639e1ec2cafea542170fdb6b9c6 Mon Sep 17 00:00:00 2001 From: PythonPan <2292551082@qq.com> Date: Thu, 12 Jun 2025 02:01:16 +0800 Subject: [PATCH] Avoid the width is negative --- src/prompt_toolkit/widgets/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prompt_toolkit/widgets/base.py b/src/prompt_toolkit/widgets/base.py index cd5365278..51cfaa27f 100644 --- a/src/prompt_toolkit/widgets/base.py +++ b/src/prompt_toolkit/widgets/base.py @@ -441,7 +441,7 @@ def _get_text_fragments(self) -> StyleAndTextTuples: ) + ( len(self.text) - get_cwidth(self.text) ) - text = (f"{{:^{width}}}").format(self.text) + text = (f"{{:^{max(0,width)}}}").format(self.text) def handler(mouse_event: MouseEvent) -> None: if (