Skip to content

feat(progress): strip ANSI sequences for sprite width calculations#207

Open
Gitkbc wants to merge 1 commit intolunarmodules:mainfrom
Gitkbc:feat-strip-ansi-progress
Open

feat(progress): strip ANSI sequences for sprite width calculations#207
Gitkbc wants to merge 1 commit intolunarmodules:mainfrom
Gitkbc:feat-strip-ansi-progress

Conversation

@Gitkbc
Copy link

@Gitkbc Gitkbc commented Feb 24, 2026

Implements #203.

Spinner and ticker width calculations now ignore ANSI escape sequences
by stripping them before computing visible width. This allows colored
or styled sprites without breaking cursor rewind behavior.

Title rendering was updated to ignore ANSI sequences for width math,
while preserving them when no truncation is required.

Copy link
Member

@Tieske Tieske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has 2 changes; titles, and sprites/progress. But you committed them all in a single commit. It's best practice to have 1 change per commit, and keep them atomic.

This is another AI generated PR, and it has the same issues, a lack of understanding of the problem.



it("strips ANSI codes when title truncation is needed", function()
local result = line.title_seq(8, "\27[31mVeryLongTitle\27[0m")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nasty edgecase, hadn't thought about it. This needs a solution I think.


- a fix
- a change
- feat(progress): strip ANSI sequences for sprite width calculations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no changelog needed for now, since there is no release yet

@Gitkbc
Copy link
Author

Gitkbc commented Feb 24, 2026

Thanks for the review and feedback, @Tieske Sir

You're right — title handling and sprite/ANSI width handling are two separate concerns and should not have been combined in a single commit. I'll split them into proper atomic commits and remove the CHANGELOG
entry since there is no release yet. Regarding the title truncation edge case: I agree the current approach
is not ideal. I'll revisit this and propose a cleaner solution that handles visible-width truncation while preserving
necessary style sequences.

I'll push an updated branch shortly. Appreciate the guidance.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants