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
F15405004: D9597.diff
Tue, Mar 18, 9:57 AM
F15402771: D9597.id23001.diff
Tue, Mar 18, 12:16 AM
F15382766: D9597.id22989.diff
Fri, Mar 14, 2:21 PM
F15334701: D9597.id22989.diff
Sat, Mar 8, 11:35 AM
Unknown Object (File)
Mon, Mar 3, 3:58 PM
Unknown Object (File)
Tue, Feb 25, 4:59 PM
Unknown Object (File)
Feb 5 2025, 10:24 AM
Unknown Object (File)
Jan 29 2025, 9:04 PM
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.