Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Fix wrong line width calculation in max_width for colored text #147

Merged
merged 2 commits into from
Aug 25, 2015

Conversation

wkentaro
Copy link
Contributor

@wkentaro wkentaro commented Aug 7, 2015

issue: #146
related to: frostming/legit#168

@wkentaro
Copy link
Contributor Author

wkentaro commented Aug 7, 2015

Before

('git branches', 12)
git branches
(<YELLOW-string: 'git branches'>, 12)
git
branches

After

('git branches', 12)
git branches
(<YELLOW-string: 'git branches'>, 12)
git branches

@wkentaro
Copy link
Contributor Author

wkentaro commented Aug 7, 2015

Please review this and hope to be merged.

@wkentaro
Copy link
Contributor Author

wkentaro commented Aug 7, 2015

This is necessary to fix a display problem in https://github.com/kennethreitz/legit .

@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch 2 times, most recently from 0b4805d to c7fe858 Compare August 7, 2015 05:31
@wkentaro
Copy link
Contributor Author

wkentaro commented Aug 7, 2015

With this, the display of legit install fixed.

before

% legit install
The following git aliases have been installed:

  git                  !legit branches
  branches
  git graft            !legit graft
  git                  !legit harvest
  harvest
  git                  !legit publish
  publish
  git                  !legit unpublish
  unpublish
  git                  !legit sprout
  sprout
  git sync             !legit sync
  git                  !legit switch
  switch
  git                  !legit resync
  resync

After

% legit install
The following git aliases have been installed:

  git branches         !legit branches
  git graft            !legit graft
  git harvest          !legit harvest
  git publish          !legit publish
  git unpublish        !legit unpublish
  git sprout           !legit sprout
  git sync             !legit sync
  git switch           !legit switch
  git resync           !legit resync

@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch from c7fe858 to 68114d5 Compare August 8, 2015 02:27
@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch from 12dde66 to c7ac904 Compare August 16, 2015 03:23
@wkentaro wkentaro changed the title Fix wrong line width calculation in max_width for colored text [WIP] Fix wrong line width calculation in max_width for colored text Aug 16, 2015
@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch from c7ac904 to 3071a0a Compare August 16, 2015 05:48
@@ -56,18 +53,18 @@ def max_width(string, cols, separator='\n'):
_row_i = 0

for word in row:
if (len(_row[_row_i]) + len(word)) < (cols + offset):
if (len(clean(_row[_row_i])) + len(word)) <= cols:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This <= is because max should include the biggest number.

@wkentaro wkentaro changed the title [WIP] Fix wrong line width calculation in max_width for colored text Fix wrong line width calculation in max_width for colored text Aug 16, 2015
@wkentaro wkentaro changed the title Fix wrong line width calculation in max_width for colored text [WIP] Fix wrong line width calculation in max_width for colored text Aug 25, 2015
@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch from 3659d12 to 30648d1 Compare August 25, 2015 15:56
@wkentaro wkentaro force-pushed the fix-max-width-for-colored-text branch from 30648d1 to d0a5237 Compare August 25, 2015 15:58
@wkentaro
Copy link
Contributor Author

strip spaces at each line's end, to get correct formatted output.

@wkentaro wkentaro changed the title [WIP] Fix wrong line width calculation in max_width for colored text Fix wrong line width calculation in max_width for colored text Aug 25, 2015
@wkentaro
Copy link
Contributor Author

Done.

jpiper added a commit that referenced this pull request Aug 25, 2015
Fix wrong line width calculation in max_width for colored text
@jpiper jpiper merged commit a47ed4f into kennethreitz:master Aug 25, 2015
@wkentaro wkentaro deleted the fix-max-width-for-colored-text branch August 25, 2015 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants