Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue splitting segments #2736

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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