Skip to content

Fix IndexError when splitting ANSI-only strings - #198

Open
yousefissa wants to merge 1 commit into
bpython:mainfrom
yousefissa:fix-194-empty-width-aware-splitlines
Open

yousefissa wants to merge 1 commit into
bpython:mainfrom
yousefissa:fix-194-empty-width-aware-splitlines

Conversation

@yousefissa

Copy link
Copy Markdown

ANSI-only strings such as a trailing color reset parse into a FmtStr with no chunks. Width-aware line splitting indexed the first chunk unconditionally, causing the IndexError reported in #194 when displaying colorized logs.

Return no lines for a chunkless FmtStr, matching plain empty-string behavior. Keep column validation unchanged. Regression tests cover reset-only and color-only input, empty construction, narrow columns, styled log wrapping, and preservation of zero-width combining text.

Fixes #194.

Validation:

  • Full suite, including doctests and terminal tests, on Python 3.10.17 and 3.14.6: 113 passed, 1 skipped, 4 expected failures on each. Terminal runs used TERM=xterm-256color with NO_COLOR unset.
  • Black checks and source/wheel builds pass.
  • Type checking reports the same 28 existing errors in window.py as unchanged upstream; none in the modified file.

AI assistance was used to implement and validate this change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexError when printing certain characters in data

1 participant