8000 Allow empty continuation. · cool-RR/python-prompt-toolkit@fc86ff0 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc86ff0

Browse files
CouleeAppsjonathanslenders
authored andcommitted
Allow empty continuation.
If continuation is an empty string, instead of ignoring it and aligning with spaces, honor the non-None but empty value and don't align to the prompt width with spaces. This is helpful if you want to configure your prompt to allow multiline editing and also want to copy the text directly from your terminal. Commit edited by Jonathan Slenders.
1 parent 06bb6de commit fc86ff0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

prompt_toolkit/shortcuts/prompt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ class PromptSession(Generic[_T]):
313313
:param prompt_continuation: Text that needs to be displayed for a multiline
314314
prompt continuation. This can either be formatted text or a callable
315315
that takes a `prompt_width`, `line_number` and `wrap_count` as input
316-
and returns formatted text.
316+
and returns formatted text. When this is `None` (the default), then
317+
`prompt_width` spaces will be used.
317318
:param complete_style: ``CompleteStyle.COLUMN``,
318319
``CompleteStyle.MULTI_COLUMN`` or ``CompleteStyle.READLINE_LIKE``.
319320
:param mouse_support: `bool` or :class:`~prompt_toolkit.filters.Filter`
@@ -367,7 +368,7 @@ def __init__(
367368
include_default_pygments_style: FilterOrBool = True,
368369
history: Optional[History] = None,
369370
clipboard: Optional[Clipboard] = None,
370-
prompt_continuation: PromptContinuationText = '',
371+
prompt_continuation: Optional[PromptContinuationText] = None,
371372
rprompt: AnyFormattedText = None,
372373
bottom_toolbar: AnyFormattedText = None,
373374
mouse_support: FilterOrBool = False,
@@ -1117,7 +1118,7 @@ def _get_continuation(
11171118

11181119
# When the continuation prompt is not given, choose the same width as
11191120
# the actual prompt.
1120-
if not continuation and is_true(self.multiline):
1121+
if continuation is None and is_true(self.multiline):
11211122
continuation = ' ' * width
11221123

11231124
return to_formatted_text(

0 commit comments

Comments
 (0)
0