Fix infinite loop when ANSI escape sequences appear at string start#3963
Closed
veeceey wants to merge 1 commit intoTextualize:masterfrom
Closed
Fix infinite loop when ANSI escape sequences appear at string start#3963veeceey wants to merge 1 commit intoTextualize:masterfrom
veeceey wants to merge 1 commit intoTextualize:masterfrom
Conversation
When strings with ANSI escape sequences at the start were printed, split_graphemes() would enter an infinite loop. This happened because: 1. ANSI escape characters (\x1b) have zero cell width 2. Zero-width characters are normally associated with the previous character 3. When no previous character exists (at string start), the index wasn't incremented 4. This caused an infinite loop in the while loop Fixed by adding an else clause to skip zero-width characters when there is no previous character to associate them with. Fixes Textualize#3958
Contributor
|
I notice you also opened #3959 for the same issue. Was this PR created by mistake? |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3958
When strings with ANSI escape sequences at the start were printed using
console.print(), the program would hang in an infinite loop. This was a critical bug introduced in version 14.3.2.Root Cause
The issue was in
split_graphemes()inrich/cells.py:\x1b) have zero cell widthChanges
spansis emptytest_ansi_at_start()to verify the fixTest plan
Before
After