diff --git a/src/vs/workbench/api/electron-browser/mainThreadSCM.ts b/src/vs/workbench/api/electron-browser/mainThreadSCM.ts index f2f391a084a..e26b516c369 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSCM.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSCM.ts @@ -15,6 +15,7 @@ import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeature import { Command } from 'vs/editor/common/modes'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { ISplice, Sequence } from 'vs/base/common/sequence'; +import { CancellationToken } from 'vs/base/common/cancellation'; class MainThreadSCMResourceGroup implements ISCMResourceGroup { @@ -73,7 +74,7 @@ class MainThreadSCMResource implements ISCMResource { public decorations: ISCMResourceDecorations ) { } - open(): TPromise { + open(): Thenable { return this.proxy.$executeResourceCommand(this.sourceControlHandle, this.groupHandle, this.handle); } @@ -241,7 +242,7 @@ class MainThreadSCMProvider implements ISCMProvider { return TPromise.as(null); } - return this.proxy.$provideOriginalResource(this.handle, uri) + return TPromise.wrap(this.proxy.$provideOriginalResource(this.handle, uri, CancellationToken.None)) .then(result => result && URI.revive(result)); } @@ -405,7 +406,7 @@ export class MainThreadSCM implements MainThreadSCMShape { if (enabled) { repository.input.validateInput = (value, pos): TPromise => { - return this._proxy.$validateInput(sourceControlHandle, value, pos).then(result => { + return TPromise.wrap(this._proxy.$validateInput(sourceControlHandle, value, pos).then(result => { if (!result) { return undefined; } @@ -414,7 +415,7 @@ export class MainThreadSCM implements MainThreadSCMShape { message: result[0], type: result[1] }; - }); + })); }; } else { repository.input.validateInput = () => TPromise.as(undefined); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 53a68deeee4..85761d96ef7 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -886,10 +886,10 @@ export interface ExtHostTerminalServiceShape { } export interface ExtHostSCMShape { - $provideOriginalResource(sourceControlHandle: number, uri: UriComponents): TPromise; + $provideOriginalResource(sourceControlHandle: number, uri: UriComponents, token: CancellationToken): Thenable; $onInputBoxValueChange(sourceControlHandle: number, value: string): void; - $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise; - $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined>; + $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Thenable; + $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Thenable<[string, number] | undefined>; $setSelectedSourceControls(selectedSourceControlHandles: number[]): Thenable; } diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts index 6aa5a833d7f..f1996d5ea4b 100644 --- a/src/vs/workbench/api/node/extHostSCM.ts +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { Event, Emitter, once } from 'vs/base/common/event'; import { debounce } from 'vs/base/common/decorators'; import { dispose, IDisposable } from 'vs/base/common/lifecycle'; -import { asWinJsPromise } from 'vs/base/common/async'; +import { asThenable } from 'vs/base/common/async'; import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands'; import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape } from './extHost.protocol'; @@ -18,6 +18,7 @@ import { comparePaths } from 'vs/base/common/comparers'; import * as vscode from 'vscode'; import { ISplice } from 'vs/base/common/sequence'; import { ILogService } from 'vs/platform/log/common/log'; +import { CancellationToken } from 'vs/base/common/cancellation'; type ProviderHandle = number; type GroupHandle = number; @@ -237,14 +238,14 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG return this._resourceStatesMap.get(handle); } - $executeResourceCommand(handle: number): TPromise { + $executeResourceCommand(handle: number): Thenable { const command = this._resourceStatesCommandsMap.get(handle); if (!command) { - return TPromise.as(null); + return Promise.resolve(null); } - return asWinJsPromise(_ => this._commands.executeCommand(command.command, ...command.arguments)); + return asThenable(() => this._commands.executeCommand(command.command, ...command.arguments)); } _takeResourceStateSnapshot(): SCMRawResourceSplice[] { @@ -558,7 +559,7 @@ export class ExtHostSCM implements ExtHostSCMShape { return inputBox; } - $provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents): TPromise { + $provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents, token: CancellationToken): Thenable { const uri = URI.revive(uriComponents); this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, uri.toString()); @@ -568,7 +569,7 @@ export class ExtHostSCM implements ExtHostSCMShape { return TPromise.as(null); } - return asWinJsPromise(token => sourceControl.quickDiffProvider.provideOriginalResource(uri, token)); + return asThenable(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token)); } $onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise { @@ -584,7 +585,7 @@ export class ExtHostSCM implements ExtHostSCMShape { return TPromise.as(null); } - $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise { + $executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Thenable { this.logService.trace('ExtHostSCM#$executeResourceCommand', sourceControlHandle, groupHandle, handle); const sourceControl = this._sourceControls.get(sourceControlHandle); @@ -602,7 +603,7 @@ export class ExtHostSCM implements ExtHostSCMShape { return group.$executeResourceCommand(handle); } - $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined> { + $validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Thenable<[string, number] | undefined> { this.logService.trace('ExtHostSCM#$validateInput', sourceControlHandle); const sourceControl = this._sourceControls.get(sourceControlHandle); @@ -615,7 +616,7 @@ export class ExtHostSCM implements ExtHostSCMShape { return TPromise.as(undefined); } - return asWinJsPromise(_ => Promise.resolve(sourceControl.inputBox.validateInput(value, cursorPosition))).then(result => { + return asThenable(() => sourceControl.inputBox.validateInput(value, cursorPosition)).then(result => { if (!result) { return TPromise.as(undefined); } diff --git a/src/vs/workbench/services/scm/common/scm.ts b/src/vs/workbench/services/scm/common/scm.ts index 7c9243f3735..e6daf562b5c 100644 --- a/src/vs/workbench/services/scm/common/scm.ts +++ b/src/vs/workbench/services/scm/common/scm.ts @@ -36,7 +36,7 @@ export interface ISCMResource { readonly resourceGroup: ISCMResourceGroup; readonly sourceUri: URI; readonly decorations: ISCMResourceDecorations; - open(): TPromise; + open(): Thenable; } export interface ISCMResourceGroup extends ISequence {