Skip to content

Commit 9629247

Browse files
authored
Merge pull request #1432 from ahoppen/dont-spam-log-progress
Only report log collection progress in `sourcekit-lsp diagnose` if we’ve made meaningful progress
2 parents e00312a + 6425a8e commit 9629247

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Sources/Diagnose/DiagnoseCommand.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import class TSCUtility.PercentProgressAnimation
2525
@MainActor
2626
private var progressBar: PercentProgressAnimation? = nil
2727

28+
/// The last progress that was reported on the progress bar. This ensures that when the progress indicator uses the
29+
/// `MultiLinePercentProgressAnimation` (eg. because stderr is redirected to a file) we don't emit status updates
30+
/// without making any real progress.
31+
@MainActor
32+
private var lastProgress: (Int, String)? = nil
33+
2834
/// A component of the diagnostic bundle that's collected in independent stages.
2935
fileprivate enum BundleComponent: String, CaseIterable, ExpressibleByArgument {
3036
case crashReports = "crash-reports"
@@ -326,7 +332,11 @@ public struct DiagnoseCommand: AsyncParsableCommand {
326332

327333
@MainActor
328334
private func reportProgress(_ state: DiagnoseProgressState, message: String) {
329-
progressBar?.update(step: Int(state.progress * 100), total: 100, text: message)
335+
let progress: (step: Int, message: String) = (Int(state.progress * 100), message)
336+
if lastProgress == nil || progress != lastProgress! {
337+
progressBar?.update(step: Int(state.progress * 100), total: 100, text: message)
338+
lastProgress = progress
339+
}
330340
}
331341

332342
@MainActor

0 commit comments

Comments
 (0)