Skip to content

Weird formatting of colored prompt message #19

@bilalq

Description

@bilalq

I cut a similar issue to the node-promptly module earlier: moxystudio/node-promptly#2

When the prompt contains colored/formatted text, the cursor is indented far to the right.

I skimmed through the code, and I think I see where the issue is:
https://github.com/isaacs/read/blob/master/lib/read.js#L56

Formatted strings end up with ANSI color codes are part of the string. Looking up the length property on them returns a misleading result. Would you accept a patch to strip ANSI codes before reading the length of the prompt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions