fix issue splitting segments

This commit is contained in:
Will McGugan 2023-01-06 14:14:48 +00:00
parent d14b304aa4
commit aa0929298b
3 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -119,7 +119,7 @@ class Segment(NamedTuple):
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)

View File

@ -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あbcdaef",
9,
(Segment("a1あb"), Segment("cdaef")),
),
],
)
def test_split_cells_emoji(text, split, result):