chiark / gitweb /
progress: Nest: Issue a report at outer phase transitions
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 00:04:35 +0000 (01:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 02:09:35 +0000 (03:09 +0100)
There's not much to say here, but without this, if the inner phase
does nothing, the user sees nothing.  Better to do something here.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
support/termprogress.rs

index c618b46845c776bef9e863709178ca61506640ae..8c8fcdfae3a294200cec657aa34680c0abda03b6 100644 (file)
@@ -195,6 +195,15 @@ impl Nest {
   pub fn start_phase(&mut self, frac: f32, desc_prefix: String) {
     self.outer_phase_base = self.outer_phase_size;
     self.outer_phase_size = frac;
+
+    let f = self.outer_phase_base / self.outer_total;
+    let value = progress::Value::Fraction { f };
+
+    self.actual_reporter.report(&ProgressInfo {
+      phase: progress::Count { desc: (&*desc_prefix).into(), value: value },
+      item:  progress::Count { desc: default(),            value: default() },
+    });
+
     self.desc_prefix = desc_prefix;
   }
 }