resolved RESOLVED UNSUBMITTED PASS · None tool calls · 0 s · Textualize/rich
(not found in data/tasks.jsonl)
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- Fix text wrapping edge case https://github.com/Textualize/rich/pull/2296
- Allow exceptions that are raised while a Live is rendered to be displayed and/or processed https://github.com/Textualize/rich/pull/2305
- Fix crashes that can happen with `inspect` when docstrings contain some special control codes https://github.com/Textualize/rich/pull/2294
--- a/rich/_wrap.py
+++ b/rich/_wrap.py
@@ -1,8 +1,8 @@
import re
from typing import Iterable, List, Tuple
-from .cells import cell_len, chop_cells
from ._loop import loop_last
+from .cells import cell_len, chop_cells
re_word = re.compile(r"\s*\S+\s*")
@@ -27,14 +27,15 @@ def divide_line(text: str, width: int, fold: bool = True) -> List[int]:
if line_position + word_length > width:
if word_length > width:
if fold:
- for last, line in loop_last(
- chop_cells(word, width, position=line_position)
- ):
+ chopped_words = chop_cells(word, max_size=width, position=0)
+ for last, line in loop_last(chopped_words):
+ if start:
+ append(start)
+
if last:
line_position = _cell_len(line)
else:
start += len(line)
- append(start)
else:
if start:
append(start)
--- a/rich/cells.py
+++ b/rich/cells.py
@@ -109,7 +109,8 @@ def set_cell_size(text: str, total: int) -> str:
# TODO: This is inefficient
# TODO: This might not work with CWJ type characters
def chop_cells(text: str, max_size: int, position: int = 0) -> List[str]:
- """Break text in to equal (cell) length strings."""
+ """Break text in to equal (cell) length strings, returning the characters in reverse
+ order"""
_get_character_cell_size = get_character_cell_size
characters = [
(character, _get_character_cell_size(character)) for character in text
........................................................................ [ 81%] ................ [100%] 88 passed in 0.19s