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, Nov 20, 6:55 PM
Unknown Object (File)
Tue, Nov 19, 2:48 AM
Unknown Object (File)
Mon, Nov 18, 7:41 AM
Unknown Object (File)
Sun, Nov 10, 12:31 PM
Unknown Object (File)
Fri, Nov 8, 5:04 AM
Unknown Object (File)
Oct 20 2024, 8:14 PM
Unknown Object (File)
Oct 20 2024, 7:29 PM
Unknown Object (File)
Oct 11 2024, 10:16 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 1175
Build 1175: [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.