Skip to content

Fix middle truncation at width boundaries - #724

Open
hugosmoreira wants to merge 1 commit into
google:masterfrom
hugosmoreira:fix/722-middle-truncation-boundaries
Open

hugosmoreira wants to merge 1 commit into
google:masterfrom
hugosmoreira:fix/722-middle-truncation-boundaries

Conversation

@hugosmoreira

Copy link
Copy Markdown

Fixes #722.

Keep text unchanged when it exactly fits the available width, and avoid retaining the entire suffix when only the ellipsis fits. Preserve the existing fallback to the full line width when fewer than three characters are available.

Add regression tests in the existing formatting test module for both reported examples, empty/short inputs, odd/even retained ends and fallback boundaries. Five assertions fail before the fix and fail again when the production change is removed.

Validation:

  • Linux Python 3.12: 277 tests pass both without and with IPython.
  • Formatting tests: 14 pass on Linux Python 3.7, 3.12 and 3.14, Windows Python 3.13, and the built wheels on Linux/Windows.
  • CI-configured pylint and wheel/sdist builds pass on Linux/Windows.
  • Windows full suite: 269 pass and eight fail in both IPython configurations; the same eight fail on unchanged master. Broader pylint and Python 3.12 type-check diagnostics also match unchanged master.

macOS and the remaining hosted version matrix were not run locally.

This branch has not been deployed

No deployments
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.

EllipsisMiddleTruncate exceeds requested width when only the ellipsis fits

1 participant