diff --git a/extensions/git/src/scmProvider.ts b/extensions/git/src/scmProvider.ts index 5d5279baf05..0fa52876fe4 100644 --- a/extensions/git/src/scmProvider.ts +++ b/extensions/git/src/scmProvider.ts @@ -5,7 +5,9 @@ 'use strict'; -import { Uri, Disposable, SCMProvider, SCMResource, SCMResourceDecorations, SCMResourceGroup, EventEmitter, Event } from 'vscode'; +import { + Uri, Disposable, SCMProvider, SCMResource, SCMResourceDecorations, SCMResourceGroup, EventEmitter, Event + commands } from 'vscode'; import { Model } from './model'; import * as path from 'path'; @@ -39,6 +41,7 @@ enum Status { class Resource implements SCMResource { get uri(): Uri { return this._uri; } + get type(): Status { return this._type; } private static Icons = { light: { @@ -104,7 +107,7 @@ class Resource implements SCMResource { return { strikeThrough: this.strikeThrough, light, dark }; } - constructor(private _uri: Uri, private type: any) { + constructor(private _uri: Uri, private _type: Status) { } } @@ -159,11 +162,21 @@ export class GitSCMProvider implements SCMProvider { console.log('commit', message); } - open(resource: SCMResource): void { - console.log('open', resource); + open(resource: Resource): Thenable { + const fileName = path.basename(resource.uri.fsPath); + const indexUri = resource.uri.with({ scheme: 'git-index' }); + + switch (resource.type) { + case Status.UNTRACKED: return commands.executeCommand('vscode.open', resource.uri); + case Status.MODIFIED: return commands.executeCommand('vscode.diff', indexUri, resource.uri, `${fileName} (HEAD) ↔ ${fileName}`); + case Status.DELETED: return commands.executeCommand('vscode.open', indexUri); + // TODO@joao: rest! + } + + return Promise.resolve(); } - drag(resource: SCMResource, resourceGroup: SCMResourceGroup): void { + drag(resource: Resource, resourceGroup: ResourceGroup): void { console.log('drag', resource, resourceGroup); } diff --git a/src/vs/workbench/api/node/extHostSCM.ts b/src/vs/workbench/api/node/extHostSCM.ts index 4a86f8fd1d6..21ce2d0cd6a 100644 --- a/src/vs/workbench/api/node/extHostSCM.ts +++ b/src/vs/workbench/api/node/extHostSCM.ts @@ -63,7 +63,7 @@ export class ExtHostSCM { supportsOriginalResource: !!provider.getOriginalResource }); - const onDidChange = debounceEvent(provider.onDidChange, (l, e) => e, 200); + const onDidChange = debounceEvent(provider.onDidChange, (l, e) => e, 100); const onDidChangeListener = onDidChange(resourceGroups => { this.cache = Object.create(null);