Skip to content

Commit

Permalink
Merge pull request #2736 from Textualize/split-fix
Browse files Browse the repository at this point in the history
fix issue splitting segments
  • Loading branch information
willmcgugan committed Jan 6, 2023
2 parents d14b304 + aa09292 commit 4bc4437
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [13.0.1] - 2022-01-06

### Fixed

- Fixed issue with Segment.split_cells for mixed single and double cell widths

## [13.0.0] - 2022-12-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion rich/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _split_cells(cls, segment: "Segment", cut: int) -> Tuple["Segment", "Segment

cell_size = get_character_cell_size

pos = int((cut / cell_length) * len(text))
pos = int((cut / cell_length) * (len(text) - 1))

before = text[:pos]
cell_pos = cell_len(before)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ def test_divide_edge_2():
("💩X💩Y💩Z💩A💩", 4, (Segment("💩X "), Segment(" Y💩Z💩A💩"))),
("XYZABC", 4, (Segment("XYZA"), Segment("BC"))),
("XYZABC", 5, (Segment("XYZAB"), Segment("C"))),
(
"a1あ11bcdaef",
9,
(Segment("a1あ11b"), Segment("cdaef")),
),
],
)
def test_split_cells_emoji(text, split, result):
Expand Down

0 comments on commit 4bc4437

Please sign in to comment.