Skip to content

Only report log collection progress in sourcekit-lsp diagnose if we’ve made meaningful progress #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Sources/Diagnose/DiagnoseCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import class TSCUtility.PercentProgressAnimation
@MainActor
private var progressBar: PercentProgressAnimation? = nil

/// The last progress that was reported on the progress bar. This ensures that when the progress indicator uses the
/// `MultiLinePercentProgressAnimation` (eg. because stderr is redirected to a file) we don't emit status updates
/// without making any real progress.
@MainActor
private var lastProgress: (Int, String)? = nil

/// A component of the diagnostic bundle that's collected in independent stages.
fileprivate enum BundleComponent: String, CaseIterable, ExpressibleByArgument {
case crashReports = "crash-reports"
Expand Down Expand Up @@ -292,7 +298,11 @@ public struct DiagnoseCommand: AsyncParsableCommand {

@MainActor
private func reportProgress(_ state: DiagnoseProgressState, message: String) {
progressBar?.update(step: Int(state.progress * 100), total: 100, text: message)
let progress: (step: Int, message: String) = (Int(state.progress * 100), message)
if lastProgress == nil || progress != lastProgress! {
progressBar?.update(step: Int(state.progress * 100), total: 100, text: message)
lastProgress = progress
}
}

@MainActor
Expand Down