Skip to content

bpython breaks line with ANSI escape code #670

Closed

Description

@laike9m

This can be easily reproduced by typing

print('\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[3
1mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[3
1mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m\033[31mOK\033[0m')

In bpython
image

In Python
image

I guess when calculating the length of output, bpython counts all chars, but not all chars are visible, thus leading to this bug.

Activity

  1. laike9m commented on Mar 19, 2017

    @laike9m
    Author

    While I managed to get over the previous issue:
    https://github.com/thomasballinger/curtsies/issues/97

    I really can't get things to work without this being fixed. I'd appreciate if you could fix it.

  2. laike9m commented on Mar 23, 2017

    @laike9m
    Author

    @sebastinas @thomasballinger What do you think? Since no other REPLs has this issue, the inconsistency between them and bpython certainly brings undesired behavior to some libraries, which I think is a serious problem.

  3. sebastinas commented on Mar 23, 2017

    @sebastinas
    Contributor

    Handling of escape characters happens in curtsies. So while this certainly is an issue that affects bpython, it needs to be fixed in curtsies. I think @thomasballinger wouldn't mind getting bug reports and/or test cases for that.

  4. thomasballinger commented on Apr 4, 2017

    @thomasballinger
    Member

    Thanks to @ata2001 the second issue you mentioned https://github.com/thomasballinger/curtsies/issues/97 is fixed. Fixing length issues is possible via the wcwidth-based width of a curtsies FmtStr. https://github.com/thomasballinger/curtsies/issues/8 is the most relevant issue for this, we should consider this bpython issue blocked on that, because the version of curtsies currently used in bpython doesn't have this width. (probably because there's no released version of curtsies with a working .width)

  5. laike9m commented on May 13, 2017

    @laike9m
    Author

    Thanks guys. Looking forward to a new release. 😄

  6. ata2001 commented on May 13, 2017

    @ata2001
    Contributor

    Test cases would not be bad for this, but I'd need some help with doing that.

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

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