Fix italic and underline ANSI escape codes - #4184
kamilkrzywanski wants to merge 2 commits into
Conversation
AnsiEscape had UNDERLINE mapped to SGR 3 (italic) and no ITALIC entry. Map italic to 3 and underline to 4, and cover both with regression tests.
|
@kamilkrzywanski, thanks! I'll try to get this cleared whenever I find the time. Thanks for your patience. |
| * compare equal to itself. | ||
| * </p> | ||
| */ | ||
| class AnsiEscapeTest { |
There was a problem hiding this comment.
Can u extend the test case for remaining format also?
| "", | ||
| "@|white key|@ = @|cyan,bold some value|@", | ||
| "\u001b[37mkey\u001b[m = \u001b[36;1msome value\u001b[m"), | ||
| // GitHub issue #4105: italic = SGR 3, underline = SGR 4 |
There was a problem hiding this comment.
not needed remove the comments
| "", | ||
| "@|italic italic text|@ and @|underline underlined text|@", | ||
| "\u001b[3mitalic text\u001b[m and \u001b[4munderlined text\u001b[m"), | ||
| // Return broken escapes as is |
There was a problem hiding this comment.
here also remove comments
There was a problem hiding this comment.
On the issue, @vy suspected AnsiEscape should also be "checked for other differences" against Jansi — that part is still open. Worth doing the full sweep: walk every constant in org.fusesource.jansi.AnsiRenderer.Code (the enum JAnsiTextRenderer.toCode used before #3070) and check it resolves in AnsiEscape. italic isn't the only casualty — try faint or blink_slow and you'll see the pattern. A quick way to check a candidate: AnsiEscape.createSequence(name) returning a bare ESC[m means the name didn't resolve, so the style silently does nothing and you get a The style attribute X is incorrect. warning on the StatusLogger.
Add missing AnsiRenderer.Code names (faint, blink_slow, etc.), extend SGR mapping tests, and drop the extra test comments from review.
|
@ramanathan1504 thanks for the review. Did the full Jansi Should be ready for another look. |
ramanathan1504
left a comment
There was a problem hiding this comment.
pattern-layout.adocpicked up only part of the new list —intensity_bold,intensity_faint,negative_on/negative_off,conceal_on/conceal_off,underline_off,blink_offandbg_defaultall work but aren't in the keyword list. add them, or say the list isn't exhaustive?- when
AnsiEscapeTestfails it printsexpected: <> but was: <>— the escape chars are invisible. could you pass the style name as the assertion message, the wayJAnsiTextRendererTestshows them as hex? and while you're in there, the@CsvSourcecovers 22 of the 43 names, the rest are free. mainstill hasUNDERLINE("3")and noITALIC— would you do the port too? no changelog entry there, the2.xone covers both.
Fixes #4105.
AnsiEscapewas missingitalic(SGR 3) and hadunderlinemapped to 3 instead of 4. After the Jansi removal, that madeitalicwarn as invalid andunderlinerender as italic.Changes
ITALIC("3")and correctUNDERLINEto"4"italicin the pattern layout style keywordsChecklist
2.xbranch if you are targeting Log4j 2; usemainotherwise./mvnw verifypassedsrc/changelog/.2.x.xdirectory