Skip to content

[BUG] Segment._split_cells doesn't handle non-unit characters well #3299

Description

@rodrigogiraoserrao

The classmethod Segment._split_cells uses a heuristic to start the search for the cut point that is too eager.
Because the algorithm implemented doesn't backtrack, one can construct example strings for which the cuts have the wrong sizes.

The two examples below show instances of the wrong result being computed.

s = Segment("🦊🦊🦊\n\n\n\n\n\n")
print(Segment._split_cells(s, 3))  # (Segment('🦊🦊🦊\n '), Segment(' \n\n\n\n'))

s = Segment("🦊🦊🦊abcdef")
print(Segment._split_cells(s, 3))  # (Segment('🦊🦊 '), Segment(' abcdef'))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions