mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
progress - make window progress get a title
This commit is contained in:
@@ -308,10 +308,10 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): vscode.Disposable {
|
||||
return extHostStatusBar.setStatusBarMessage(text, timeoutOrThenable);
|
||||
},
|
||||
withWindowProgress: proposedApiFunction(extension, <R>(task: (progress: vscode.Progress<string>, token: vscode.CancellationToken) => Thenable<R>): Thenable<R> => {
|
||||
return extHostProgress.withWindowProgress(extension, task);
|
||||
withWindowProgress: proposedApiFunction(extension, <R>(title: string, task: (progress: vscode.Progress<string>, token: vscode.CancellationToken) => Thenable<R>): Thenable<R> => {
|
||||
return extHostProgress.withWindowProgress(extension, title, task);
|
||||
}),
|
||||
withScmProgress: proposedApiFunction(extension, (task: (progress: vscode.Progress<number>) => Thenable<any>) => {
|
||||
withScmProgress: proposedApiFunction(extension, <R>(task: (progress: vscode.Progress<number>) => Thenable<R>) => {
|
||||
return extHostProgress.withScmProgress(extension, task);
|
||||
}),
|
||||
createOutputChannel(name: string): vscode.OutputChannel {
|
||||
|
||||
@@ -186,7 +186,9 @@ export abstract class MainThreadOutputServiceShape {
|
||||
}
|
||||
|
||||
export abstract class MainThreadProgressShape {
|
||||
$progressStart(handle: number, extensionId: string, location: string): void { throw ni(); }
|
||||
|
||||
$startWindow(handle: number, title: string): void { throw ni(); };
|
||||
$startScm(handle: number): void { throw ni(); };
|
||||
$progressReport(handle: number, message: string): void { throw ni(); }
|
||||
$progressEnd(handle: number): void { throw ni(); }
|
||||
}
|
||||
|
||||
@@ -17,18 +17,20 @@ export class ExtHostProgress {
|
||||
this._proxy = proxy;
|
||||
}
|
||||
|
||||
withWindowProgress<R>(extension: IExtensionDescription, task: (progress: Progress<string>, token: CancellationToken) => Thenable<R>): Thenable<R> {
|
||||
return this._withProgress(extension, 'window', task);
|
||||
withWindowProgress<R>(extension: IExtensionDescription, title: string, task: (progress: Progress<string>, token: CancellationToken) => Thenable<R>): Thenable<R> {
|
||||
const handle = this._handles++;
|
||||
this._proxy.$startWindow(handle, title);
|
||||
return this._withProgress(handle, task);
|
||||
}
|
||||
|
||||
withScmProgress<R>(extension: IExtensionDescription, task: (progress: Progress<number>) => Thenable<R>): Thenable<R> {
|
||||
return this._withProgress(extension, 'scm', task);
|
||||
const handle = this._handles++;
|
||||
this._proxy.$startScm(handle);
|
||||
return this._withProgress(handle, task);
|
||||
}
|
||||
|
||||
private _withProgress<R>(extension: IExtensionDescription, type: string, task: (progress: Progress<any>, token: CancellationToken) => Thenable<R>): Thenable<R> {
|
||||
const handle = this._handles++;
|
||||
private _withProgress<R>(handle: number, task: (progress: Progress<any>, token: CancellationToken) => Thenable<R>): Thenable<R> {
|
||||
|
||||
this._proxy.$progressStart(handle, extension.id, type);
|
||||
const progress = {
|
||||
report: (message: string) => {
|
||||
this._proxy.$progressReport(handle, message);
|
||||
|
||||
@@ -21,23 +21,22 @@ export class MainThreadProgress extends MainThreadProgressShape {
|
||||
}
|
||||
|
||||
|
||||
$progressStart(handle: number, extensionId: string, where: string): void {
|
||||
$startWindow(handle: number, title: string): void {
|
||||
const task = this._createTask(handle);
|
||||
this._progressService.withWindowProgress(title, task);
|
||||
}
|
||||
|
||||
const task = (progress: IProgress<any>) => {
|
||||
$startScm(handle: number): void {
|
||||
const task = this._createTask(handle);
|
||||
this._progressService.withViewletProgress('workbench.view.scm', task);
|
||||
}
|
||||
|
||||
private _createTask(handle: number) {
|
||||
return (progress: IProgress<any>) => {
|
||||
return new TPromise<any>(resolve => {
|
||||
this.progress.set(handle, { resolve, progress });
|
||||
});
|
||||
};
|
||||
|
||||
switch (where) {
|
||||
case 'window':
|
||||
this._progressService.withWindowProgress(task);
|
||||
break;
|
||||
case 'scm':
|
||||
this._progressService.withViewletProgress('workbench.view.scm', task);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$progressReport(handle: number, message: any): void {
|
||||
|
||||
Reference in New Issue
Block a user