@@ -860,6 +860,19 @@ function removeUnbalancedInlineBackticks(value: string): string {
860860 return value . trimStart ( ) . startsWith ( "`" ) ? value . replaceAll ( "`" , "'" ) : value . replaceAll ( "`" , "" ) ;
861861}
862862
863+ function removeUnbalancedItalicUnderscore ( value : string ) : string {
864+ const chars = Array . from ( value ) ;
865+ const underscoreCount = chars . filter ( ( char ) => char === "_" ) . length ;
866+ if ( underscoreCount % 2 === 0 ) {
867+ return value ;
868+ }
869+ const trimmed = value . trimStart ( ) ;
870+ if ( trimmed . startsWith ( "_" ) ) {
871+ return trimmed . slice ( 1 ) ;
872+ }
873+ return value . replace ( / _ ( [ ^ _ ] * ) $ / , "$1" ) ;
874+ }
875+
863876function compactPlainProgressLine ( line : string , maxChars : number ) : string {
864877 const head = sliceCodePoints ( line , 0 , maxChars - 1 ) . trimEnd ( ) ;
865878 const boundary = head . search ( / \s + \S * $ / u) ;
@@ -888,8 +901,10 @@ function compactChannelProgressDraftLine(line: string, maxChars: number): string
888901 if ( detailLimit < 8 ) {
889902 return undefined ;
890903 }
891- return removeUnbalancedInlineBackticks (
892- `${ prefix } ${ compactProgressLineDetail ( detail , detailLimit ) } ` ,
904+ return removeUnbalancedItalicUnderscore (
905+ removeUnbalancedInlineBackticks (
906+ `${ prefix } ${ compactProgressLineDetail ( detail , detailLimit ) } ` ,
907+ ) ,
893908 ) ;
894909 } ;
895910
@@ -911,7 +926,9 @@ function compactChannelProgressDraftLine(line: string, maxChars: number): string
911926 }
912927 }
913928
914- return removeUnbalancedInlineBackticks ( compactPlainProgressLine ( normalized , maxChars ) ) ;
929+ return removeUnbalancedItalicUnderscore (
930+ removeUnbalancedInlineBackticks ( compactPlainProgressLine ( normalized , maxChars ) ) ,
931+ ) ;
915932}
916933
917934function getProgressDraftLineText ( line : string | ChannelProgressDraftLine ) : string {
0 commit comments