kennethreitz / clint

Python Command-line Application Tools
http://pypi.python.org/pypi/clint/
ISC License
95 stars 19 forks source link

clint.textui.formatter.max_width: unexpected newline when using colorred_string #146

Closed wkentaro closed 9 years ago

wkentaro commented 9 years ago

This is related to https://github.com/kennethreitz/legit/issues/168

# test_formatter.py

from clint.textui import colored
from clint.textui import columns

print(columns(['git branches', 20]))
print(columns([colored.yellow('git branches'), 20]))
$ python test_formatter.py
git branches
git
branches

This behavior is unexpected, because len('git branches') is only 12.

So it should be

$ python test_formatter.py
git branches
git branches
wkentaro commented 9 years ago

This seems to be caused by colored string, and with https://github.com/kennethreitz/clint/pull/147, the output will be

$ python ~/test_formatter.py
git branches
git branches
jpiper commented 9 years ago

Thanks for the PR!