5
5
"encoding/json"
6
6
"errors"
7
7
"fmt"
8
+ "strings"
8
9
"time"
9
10
10
11
"github.com/cli/go-gh/v2/pkg/api"
@@ -494,7 +495,7 @@ func displayTableStats(stats *StatsCollector) {
494
495
status = "NOT ENOUGH"
495
496
statusColor = yellow
496
497
}
497
-
498
+
498
499
mcColor := green
499
500
dnmColor := green
500
501
if repoStat .SkippedMergeConf > 0 {
@@ -506,22 +507,25 @@ func displayTableStats(stats *StatsCollector) {
506
507
mcRaw := fmt .Sprintf ("%d" , repoStat .SkippedMergeConf )
507
508
dnmRaw := fmt .Sprintf ("%d" , repoStat .SkippedCriteria )
508
509
skippedRaw := fmt .Sprintf ("%s (MC), %s (DNM)" , mcRaw , dnmRaw )
509
-
510
- // Pad all fields using raw values
510
+
511
511
repoName := truncate (repoStat .RepoName , repoCol )
512
512
combined := fmt .Sprintf ("%*d" , colWidths [1 ], repoStat .CombinedCount )
513
- skipped := fmt .Sprintf ("%-*s" , colWidths [2 ], skippedRaw )
514
- statusPadded := fmt .Sprintf ("%-*s" , colWidths [3 ], status )
515
-
516
- // Now colorize only the numbers and status
517
- mcColored := colorize (mcRaw , mcColor )
518
- dnmColored := colorize (dnmRaw , dnmColor )
519
- skippedColored := skippedRaw
520
- skippedColored = strings .Replace (skippedColored , mcRaw , mcColored , 1 )
521
- skippedColored = strings .Replace (skippedColored , dnmRaw , dnmColored , 1 )
513
+ // Pad skippedRaw to colWidths[2] before coloring
514
+ skippedPadded := fmt .Sprintf ("%-*s" , colWidths [2 ], skippedRaw )
515
+ // Colorize only the numbers in the padded string
516
+ mcIdx := strings .Index (skippedPadded , mcRaw )
517
+ dnmIdx := strings .Index (skippedPadded , dnmRaw )
518
+ skippedColored := skippedPadded
519
+ if mcIdx != - 1 {
520
+ skippedColored = skippedColored [:mcIdx ] + colorize (mcRaw , mcColor ) + skippedColored [mcIdx + len (mcRaw ):]
521
+ }
522
+ if dnmIdx != - 1 {
523
+ dnmIdx = strings .Index (skippedColored , dnmRaw ) // recalc in case mcRaw and dnmRaw overlap
524
+ skippedColored = skippedColored [:dnmIdx ] + colorize (dnmRaw , dnmColor ) + skippedColored [dnmIdx + len (dnmRaw ):]
525
+ }
522
526
statusColored := colorize (status , statusColor )
523
- statusColored = fmt .Sprintf ("%-*s" , colWidths [3 ]+ len (statusColored )- len (status ), statusColored ) // pad after coloring
524
-
527
+ statusColored = fmt .Sprintf ("%-*s" , colWidths [3 ]+ len (statusColored )- len (status ), statusColored )
528
+
525
529
fmt .Printf (
526
530
"│ %-*s │ %s │ %s │ %s │\n " ,
527
531
repoCol , repoName ,
0 commit comments