@@ -139,9 +139,8 @@ public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|n
139139 $ attr = $ cursor ->attr ;
140140
141141 switch ($ type ) {
142- case 'default ' :
143- $ style = 'default ' ;
144- break ;
142+ case 'label ' : $ style = 'label ' ; break ;
143+ case 'default ' : $ style = 'default ' ; break ;
145144
146145 case 'integer ' :
147146 $ style = 'num ' ;
@@ -468,7 +467,7 @@ protected function style(string $style, string $value, array $attr = []): string
468467
469468 $ map = static ::$ controlCharsMap ;
470469 $ startCchr = $ this ->colors ? "\033[m \033[ {$ this ->styles ['default ' ]}m " : '' ;
471- $ endCchr = $ this ->colors ? "\033[m \033[ {$ this ->styles [$ style ]}m " : '' ;
470+ $ endCchr = $ this ->colors ? "\033[m \033[ {$ this ->styles [' label ' === $ style ? ' default ' : $ style ]}m " : '' ;
472471 $ value = preg_replace_callback (static ::$ controlCharsRx , function ($ c ) use ($ map , $ startCchr , $ endCchr ) {
473472 $ s = $ startCchr ;
474473 $ c = $ c [$ i = 0 ];
@@ -487,11 +486,11 @@ protected function style(string $style, string $value, array $attr = []): string
487486 }, $ value );
488487 }
489488
490- if ($ this ->colors ) {
489+ if ($ this ->colors && '' !== $ value ) {
491490 if ($ cchrCount && "\033" === $ value [0 ]) {
492491 $ value = substr ($ value , \strlen ($ startCchr ));
493492 } else {
494- $ value = "\033[ {$ this ->styles [$ style ]}m " .$ value ;
493+ $ value = "\033[ {$ this ->styles [' label ' === $ style ? ' default ' : $ style ]}m " .$ value ;
495494 }
496495 if ($ cchrCount && str_ends_with ($ value , $ endCchr )) {
497496 $ value = substr ($ value , 0 , -\strlen ($ endCchr ));
@@ -510,10 +509,15 @@ protected function style(string $style, string $value, array $attr = []): string
510509 }
511510 }
512511 if (isset ($ attr ['href ' ])) {
512+ if ('label ' === $ style ) {
513+ $ value .= '^ ' ;
514+ }
513515 $ value = "\033]8;; {$ attr ['href ' ]}\033\\{$ value }\033]8;; \033\\" ;
514516 }
515- } elseif ($ attr ['if_links ' ] ?? false ) {
516- return '' ;
517+ }
518+
519+ if ('label ' === $ style && '' !== $ value ) {
520+ $ value .= ' ' ;
517521 }
518522
519523 return $ value ;
0 commit comments