Skip to content
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

Incorrect prompt width when control chars are used #22

Closed
gwenn opened this issue Feb 23, 2016 · 2 comments
Closed

Incorrect prompt width when control chars are used #22

gwenn opened this issue Feb 23, 2016 · 2 comments

Comments

@gwenn
Copy link
Collaborator

gwenn commented Feb 23, 2016

extern crate unicode_width;

fn main () {
    let s = "\x1b[1;32m>>\x1b[0m ";
    println!("{}", unicode_width::UnicodeWidthStr::width(s)); // 12
    let s = ">> ";
    println!("{}", unicode_width::UnicodeWidthStr::width(s)); // should be 3
}
@gwenn
Copy link
Collaborator Author

gwenn commented Feb 23, 2016

I tried term_grid crate with no success:

extern crate term_grid;

use term_grid::Cell;

fn main () {
    let s = "\x1b[1;32m>>\x1b[0m ";
    let cell: Cell = s.into();
    println!("{}", cell.width); // 12
}

@kkawakam
Copy link
Owner

Fixed by PR #23

gwenn pushed a commit to gwenn/rustyline that referenced this issue Nov 30, 2018
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

No branches or pull requests

2 participants