Skip to content

Commit

Permalink
Fix some regex handling and add another example
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Jul 12, 2024
1 parent aa25eb9 commit 58c8acf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion examples/full-screen/simple-demos/word-wrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_line_prefix(lineno, wrap_count):
if wrap_count
else [],
),
# Truncating (only wrap the first timle around)
# Truncating (only wrap the first time around)
Window(
BufferControl(buffer=buff),
wrap_lines=True,
Expand All @@ -100,6 +100,16 @@ def get_line_prefix(lineno, wrap_count):
if wrap_count > 0
else fallback(line, lineno, wrap_count, start, end),
),
# Split only after vowels
Window(
BufferControl(buffer=buff),
wrap_lines=True,
wrap_finder=Window._whitespace_wrap_finder(
sep="[aeiouyAEIOUY]",
split="after",
continuation=to_formatted_text("-"),
),
),
]
),
floats=[
Expand Down
4 changes: 2 additions & 2 deletions src/prompt_toolkit/layout/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,9 +1955,9 @@ def _whitespace_wrap_finder(
f"Pattern {sep_re.pattern!r} has capture group – use non-capturing groups instead"
)
elif split == "after":
sep_re = re.compile("(?<={sep_re.pattern})()")
sep_re = re.compile(f"(?={sep_re.pattern})()")
elif split == "before":
sep_re = re.compile("(?={sep_re.pattern})()")
sep_re = re.compile(f"(?<={sep_re.pattern})()")
elif split == "remove":
sep_re = re.compile(f"({sep_re.pattern})")
else:
Expand Down

0 comments on commit 58c8acf

Please sign in to comment.