From c35d3232927463419b9a7e1dab707ecaea614b89 Mon Sep 17 00:00:00 2001 From: NovusEdge Date: Mon, 10 Aug 2026 20:56:09 +0300 Subject: [PATCH] fix(tui): draw the bar from apk's first package, not its hundredth apk right-pads the done counter to the total's width, so early lines read ( 1/263). apkCountRe required a digit right after (, so it matched no line until the counter reached the total's digit count. On a 263-package apply the bar stayed blank for the first 99 packages. \s* absorbs the padding, matching what pacmanCountRe already does. --- internal/tui/pkgprogress.go | 7 +++++-- internal/tui/pkgprogress_test.go | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/tui/pkgprogress.go b/internal/tui/pkgprogress.go index f5a2ba8..3546a03 100644 --- a/internal/tui/pkgprogress.go +++ b/internal/tui/pkgprogress.go @@ -24,8 +24,11 @@ var ansiRe = regexp.MustCompile(`\x1b(?:\[[0-9;]*[A-Za-z]|[78])`) var ( // apkCountRe matches apk's per-package line: "(147/263) Installing - // gtk+3.0-3.24.43-r0". apk always capitalizes "Installing". - apkCountRe = regexp.MustCompile(`^\((\d+)/(\d+)\)\s+Installing\s+(\S+)`) + // gtk+3.0-3.24.43-r0". apk always capitalizes "Installing". It + // right-pads the done counter to the total's width, so early lines read + // "( 1/263)"; \s* after "(" absorbs that padding, else no bar draws + // until the counter reaches the total's digit count. + apkCountRe = regexp.MustCompile(`^\(\s*(\d+)/(\d+)\)\s+Installing\s+(\S+)`) // pacmanCountRe matches pacman's per-package line: "(3/12) installing // foo". pacman lowercases "installing", which is what tells the two // apart. diff --git a/internal/tui/pkgprogress_test.go b/internal/tui/pkgprogress_test.go index 15185b4..913829c 100644 --- a/internal/tui/pkgprogress_test.go +++ b/internal/tui/pkgprogress_test.go @@ -13,6 +13,11 @@ func TestParseProgress(t *testing.T) { "(147/263) Installing gtk+3.0-3.24.43-r0", Progress{Done: 147, Total: 263, Frac: 147.0 / 263, Label: "gtk+3.0-3.24.43-r0"}, }, + { + "apk per-package, padded counter", + "( 1/263) Installing dbus-libs-1.16.2-r2", + Progress{Done: 1, Total: 263, Frac: 1.0 / 263, Label: "dbus-libs-1.16.2-r2"}, + }, { "apk percent bar, hashes", "45% ####################",