-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap adds a new line to strings containing ANSI codes #58
Comments
Figured this one out but have no idea how to fix it. By the time we get to the 3rd and last printed character, we have moved The logic that matters: if i < len(b)-1 {
addNewline()
} The remaining 3 characters are How do we detect there are no more printable characters before we add the new line?
|
We really appreciate you looking into this, @mikelorant. If this is causing a regression in Lip Gloss (currently |
Might be better off to delay promoting the master branch of Lip Gloss to a release. This gives @aymanbagabas some time to investigate this without rolling back his work. I think if we can come up with an approach on how to handle this edge case that the implementation won't be too difficult. |
Cool, makes sense to me. In general, moving over to |
Be aware that this really needs to be done in parallel with Bubbles as it is so dependent on Lip Gloss. I've done some auditing and there are even parts of Bubbles that assume all strings can be handled as runes. These needed to brought into using the new methods provided by |
Properly count escape codes, better handling of breakpoints, and only break word/breakpoint when necessary. Fixes: #58
@mikelorant thanks for reporting this. PR #59 includes a fix for this along with handling more edge cases. Let me know if you find any other bugs. |
@aymanbagabas I was still trying to come up with ideas on how to tackle it, and you've got a fix! Amazing work. 👏 |
* fix(term): ansi: account for some wrap edge cases Properly count escape codes, better handling of breakpoints, and only break word/breakpoint when necessary. Fixes: #58 * Update wrap.go * Update wrap.go * Update wrap.go * Update wrap.go * wip * fix * fix: preserve spaces in ansi strings and account for breakpoints Breakpoints are now respected and wrapped properly. Support non-breaking spaces * Update wrap.go
Upgrade dependencies to latest stable versions. As part of this dependency upgrade, the `term` package is being updated to include an important fix for wrapping strings containing ANSI codes. See charmbracelet/x/issues/58 for more details. Signed-off-by: Michael Lorant <[email protected]>
Making a note that this is confirmed fixed. |
Upgrade dependencies to latest stable versions. As part of this dependency upgrade, the `term` package is being updated to include an important fix for wrapping strings containing ANSI codes. See charmbracelet/x/issues/58 for more details. Signed-off-by: Michael Lorant <[email protected]>
When using the
Wrap
function as part of the ANSI package, strings containing ANSI codes that have a printable width equal to the wrap value have a new line appended.Following code demonstrates this issue:
This is a causing a regression in Lip Gloss when using the style
Width
function to force a string to a specific width.As the only test function that calls
Wrap
isTestSmartWrap
, this test case can be added to check for this problem.This test case can be made to pass changing the following line:
x/exp/term/ansi/wrap.go
Line 355 in 62a6965
To:
However this causes other tests to fail, so there is some other edge cases to consider.
@aymanbagabas Let me know if there is anything else I need to provide to debug this issue further.
The text was updated successfully, but these errors were encountered: