Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit cfd7957

Browse files
committed
Don't report complete progress if never reported an update
1 parent c5159ba commit cfd7957

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/src/progress.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let progressIds = 1
2525
const createReporter = (connection: MessageConnection, logger: Logger, title?: string): ProgressReporter => {
2626
const id = String(progressIds++)
2727
const subject = new Subject<Progress>()
28-
tryLogError(logger, () => connection.sendNotification(WindowProgressNotification.type, { id, title }))
28+
let didReport = false
2929
subject
3030
.pipe(
3131
// Convert a next() with percentage >= 100 to a complete() for safety
@@ -42,6 +42,7 @@ const createReporter = (connection: MessageConnection, logger: Logger, title?: s
4242
)
4343
.subscribe({
4444
next: progress => {
45+
didReport = true
4546
tryLogError(logger, () => {
4647
connection.sendNotification(WindowProgressNotification.type, {
4748
...progress,
@@ -54,14 +55,19 @@ const createReporter = (connection: MessageConnection, logger: Logger, title?: s
5455
tryLogError(logger, () => {
5556
// window/progress doesn't support erroring the progress,
5657
// but we can emulate by hiding the progress and showing an error
57-
connection.sendNotification(WindowProgressNotification.type, { id, done: true })
58+
if (didReport) {
59+
connection.sendNotification(WindowProgressNotification.type, { id, done: true })
60+
}
5861
connection.sendNotification(ShowMessageNotification.type, {
5962
message: err.message,
6063
type: MessageType.Error,
6164
})
6265
})
6366
},
6467
complete: () => {
68+
if (!didReport) {
69+
return
70+
}
6571
tryLogError(logger, () => {
6672
connection.sendNotification(WindowProgressNotification.type, { id, percentage: 100, done: true })
6773
})

0 commit comments

Comments
 (0)