Skip to content

Commit 3fe9b61

Browse files
committed
Merge branch 'main' into prompt-toolkit
2 parents 10380b1 + 8f2f42e commit 3fe9b61

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

cmd2/argparse_completer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def _format_completions(self, arg_state: _ArgumentState, completions: list[str]
582582
# Generate the hint table string
583583
console = Cmd2GeneralConsole()
584584
with console.capture() as capture:
585-
console.print(hint_table, end="")
585+
console.print(hint_table, end="", soft_wrap=False)
586586
self._cmd2_app.formatted_completions = capture.get()
587587
return cast(list[str], completions)
588588

cmd2/cmd2.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,14 @@ def print_to(
13001300
:param sep: string to write between printed text. Defaults to " ".
13011301
:param end: string to write at end of printed text. Defaults to a newline.
13021302
:param style: optional style to apply to output
1303-
:param soft_wrap: Enable soft wrap mode. If True, lines of text will not be
1304-
word-wrapped or cropped to fit the terminal width. Defaults to True.
1303+
:param soft_wrap: Enable soft wrap mode. Defaults to True.
1304+
If True, text that doesn't fit will run on to the following line,
1305+
just like with print(). This is useful for raw text and logs.
1306+
If False, Rich wraps text to fit the terminal width.
1307+
Set this to False when printing structured Renderables like
1308+
Tables, Panels, or Columns to ensure they render as expected.
1309+
For example, when soft_wrap is True Panels truncate text
1310+
which is wider than the terminal.
13051311
:param emoji: If True, Rich will replace emoji codes (e.g., :smiley:) with their
13061312
corresponding Unicode characters. Defaults to False.
13071313
:param markup: If True, Rich will interpret strings with tags (e.g., [bold]hello[/bold])
@@ -4163,7 +4169,7 @@ def print_topics(self, header: str, cmds: list[str] | None, cmdlen: int, maxcol:
41634169
header_grid = Table.grid()
41644170
header_grid.add_row(Text(header, style=Cmd2Style.HELP_HEADER))
41654171
header_grid.add_row(Rule(characters=self.ruler, style=Cmd2Style.TABLE_BORDER))
4166-
self.poutput(header_grid)
4172+
self.poutput(header_grid, soft_wrap=False)
41674173

41684174
# Subtract 1 from maxcol to account for a one-space right margin.
41694175
maxcol = min(maxcol, ru.console_width()) - 1
@@ -4231,7 +4237,7 @@ def _print_documented_command_topics(self, header: str, cmds: list[str], verbose
42314237
topics_table.add_row(command, cmd_desc)
42324238

42334239
category_grid.add_row(topics_table)
4234-
self.poutput(category_grid)
4240+
self.poutput(category_grid, soft_wrap=False)
42354241
self.poutput()
42364242

42374243
def render_columns(self, str_list: list[str] | None, display_width: int = 80) -> str:
@@ -4528,7 +4534,7 @@ def do_set(self, args: argparse.Namespace) -> None:
45284534
self.last_result[param] = settable.value
45294535

45304536
self.poutput()
4531-
self.poutput(settable_table)
4537+
self.poutput(settable_table, soft_wrap=False)
45324538
self.poutput()
45334539

45344540
@classmethod

0 commit comments

Comments
 (0)