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
F14036860: D9597.diff
Sun, Nov 10, 12:31 PM
F14027081: D9597.id22989.diff
Fri, Nov 8, 5:04 AM
F13985392: D9597.id23002.diff
Sun, Oct 20, 8:14 PM
F13985293: D9597.id.diff
Sun, Oct 20, 7:29 PM
Unknown Object (File)
Oct 11 2024, 10:16 PM
Unknown Object (File)
Oct 1 2024, 7:04 AM
Unknown Object (File)
Sep 24 2024, 3:16 AM
Unknown Object (File)
Sep 18 2024, 11:25 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
Branch
utf8color
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1170
Build 1170: [Placeholder Plan] Wait for 30 Seconds

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.