Skip to content

Fix line length in Select when line has ASCII colors#347

Open
LandStander27 wants to merge 4 commits into
console-rs:mainfrom
LandStander27:main
Open

Fix line length in Select when line has ASCII colors#347
LandStander27 wants to merge 4 commits into
console-rs:mainfrom
LandStander27:main

Conversation

@LandStander27

Copy link
Copy Markdown

I was trying to use Select, but because I have ASCII color codes in my items, it was calculating the line length incorrectly, causing problems with rendering. For example, pressing Up would move the entire selection prompt up as well, deleting the line above the prompt.

So, I made a function len_visible() on &str that calculates the length, excluding the color codes.

@djc

djc commented May 23, 2026

Copy link
Copy Markdown
Member

There's API for this in the console crate which dialoguer already depends on -- would be better to reuse that.

@LandStander27

LandStander27 commented May 24, 2026

Copy link
Copy Markdown
Author

Sorry, didn't see that.

@djc

djc commented Jun 1, 2026

Copy link
Copy Markdown
Member

Can you do a separate PR for resolving the clippy lints, please?

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.

2 participants