Page MenuHomePhabricator

Ignore colors and formatting when determining string length.
ClosedPublic

Authored by joshuaspence on Jun 17 2014, 7:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 4, 1:38 PM
Unknown Object (File)
Sat, Aug 31, 5:10 AM
Unknown Object (File)
Sat, Aug 31, 5:10 AM
Unknown Object (File)
Sat, Aug 31, 5:10 AM
Unknown Object (File)
Sat, Aug 31, 5:10 AM
Unknown Object (File)
Sat, Aug 31, 5:01 AM
Unknown Object (File)
Thu, Aug 29, 12:58 AM
Unknown Object (File)
Tue, Aug 27, 1:50 AM
Subscribers

Details

Summary

When calculating the length of a string with phutil_utf8_console_strlen, escape codes shouldn't contribute any width to the string.

This change allows for the widths of a PhutilConsoleTable table to be determined correctly when using rows containing formatting and/or colors.

Test Plan

Before

Before (99×495 px, 10 KB)

After

After (97×372 px, 10 KB)

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence retitled this revision from to Ignore colors and formatting when determining string length..
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.

Consider adding a unit test or two, there should already be a test case.

Does /s do anything in this case? There's no . in the regexp. (For that matter, I don't see a way for U to ever affect behavior.)

This revision is now accepted and ready to land.Jun 17 2014, 11:20 AM
joshuaspence edited edge metadata.
  • Remove unnecessary sU from regex.
  • Add unit tests.