Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,008 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Progress, ProgressLocation } from "vscode"; | ||
import * as wrappers from "./wrappers"; | ||
|
||
export class ProgressView { | ||
private resolver: (value?: any) => void; | ||
private view: Progress<{ message?: string, increment?: number }>; | ||
private currentProgress: number; | ||
private currentText: string; | ||
private promise: Promise<void>; | ||
|
||
constructor(private readonly vscode: wrappers.VSCode, public readonly title?: string) { | ||
this.currentProgress = 0; | ||
} | ||
|
||
public show(): void { | ||
this.vscode.withProgress({ | ||
cancellable: false, | ||
location: ProgressLocation.Notification, | ||
title: this.title, | ||
}, (progress) => { | ||
this.view = progress; | ||
this.promise = new Promise((resolve) => this.resolver = resolve); | ||
return this.promise; | ||
}); | ||
} | ||
|
||
public get text() { return this.currentText; } | ||
|
||
public get progress() { return this.currentProgress; } | ||
|
||
public update(message: string, increment: number) { | ||
this.currentProgress += increment; | ||
this.currentText = message; | ||
|
||
if (this.currentProgress < 0) { this.currentProgress = 0; } | ||
|
||
this.view.report({ message, increment }); | ||
} | ||
|
||
public close() { | ||
this.resolver(); | ||
} | ||
|
||
public async wait() { | ||
return this.promise; | ||
} | ||
} |
Oops, something went wrong.