Skip to content

Commit

Permalink
Use URI for the SCM part of the protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Feb 8, 2018
1 parent 40e59c8 commit 53df86a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/vs/workbench/api/electron-browser/mainThreadSCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

import { TPromise } from 'vs/base/common/winjs.base';
import URI from 'vs/base/common/uri';
import URI, { UriComponents } from 'vs/base/common/uri';
import Event, { Emitter } from 'vs/base/common/event';
import { assign } from 'vs/base/common/objects';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -212,7 +212,7 @@ class MainThreadSCMProvider implements ISCMProvider {
this.handle,
groupHandle,
handle,
URI.parse(sourceUri),
URI.revive(sourceUri),
group,
decorations
);
Expand Down Expand Up @@ -241,8 +241,8 @@ class MainThreadSCMProvider implements ISCMProvider {
return TPromise.as(null);
}

return this.proxy.$provideOriginalResource(this.handle, uri.toString())
.then(result => result && URI.parse(result));
return this.proxy.$provideOriginalResource(this.handle, uri)
.then(result => result && URI.revive(result));
}

toJSON(): any {
Expand Down Expand Up @@ -284,8 +284,8 @@ export class MainThreadSCM implements MainThreadSCMShape {
this._disposables = dispose(this._disposables);
}

$registerSourceControl(handle: number, id: string, label: string, rootUri: string | undefined): void {
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri && URI.parse(rootUri), this.scmService);
$registerSourceControl(handle: number, id: string, label: string, rootUri: UriComponents | undefined): void {
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri && URI.revive(rootUri), this.scmService);
const repository = this.scmService.registerSCMProvider(provider);
this._repositories[handle] = repository;

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export interface SCMGroupFeatures {

export type SCMRawResource = [
number /*handle*/,
string /*resourceUri*/,
UriComponents /*resourceUri*/,
string[] /*icons: light, dark*/,
string /*tooltip*/,
boolean /*strike through*/,
Expand All @@ -418,7 +418,7 @@ export type SCMRawResourceSplices = [
];

export interface MainThreadSCMShape extends IDisposable {
$registerSourceControl(handle: number, id: string, label: string, rootUri: string | undefined): void;
$registerSourceControl(handle: number, id: string, label: string, rootUri: UriComponents | undefined): void;
$updateSourceControl(handle: number, features: SCMProviderFeatures): void;
$unregisterSourceControl(handle: number): void;

Expand Down Expand Up @@ -691,7 +691,7 @@ export interface ExtHostTerminalServiceShape {
}

export interface ExtHostSCMShape {
$provideOriginalResource(sourceControlHandle: number, uri: string): TPromise<string>;
$provideOriginalResource(sourceControlHandle: number, uri: UriComponents): TPromise<UriComponents>;
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void>;
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void>;
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined>;
Expand Down
16 changes: 8 additions & 8 deletions src/vs/workbench/api/node/extHostSCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import URI from 'vs/base/common/uri';
import URI, { UriComponents } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import Event, { Emitter, once } from 'vs/base/common/event';
import { debounce } from 'vs/base/common/decorators';
Expand Down Expand Up @@ -256,7 +256,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
const handle = this._resourceHandlePool++;
this._resourceStatesMap.set(handle, r);

const sourceUri = r.resourceUri.toString();
const sourceUri = r.resourceUri;
const iconPath = getIconPath(r.decorations);
const lightIconPath = r.decorations && getIconPath(r.decorations.light) || iconPath;
const darkIconPath = r.decorations && getIconPath(r.decorations.dark) || iconPath;
Expand All @@ -282,7 +282,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
const letter = r.decorations && r.decorations.letter || undefined;
const color = r.decorations && r.decorations.color || undefined;

const rawResource = [handle, sourceUri, icons, tooltip, strikeThrough, faded, source, letter, color] as SCMRawResource;
const rawResource = [handle, <UriComponents>sourceUri, icons, tooltip, strikeThrough, faded, source, letter, color] as SCMRawResource;

return { rawResource, handle };
});
Expand Down Expand Up @@ -406,7 +406,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
private _rootUri?: vscode.Uri
) {
this._inputBox = new ExtHostSCMInputBox(_extension, this._proxy, this.handle);
this._proxy.$registerSourceControl(this.handle, _id, _label, _rootUri && _rootUri.toString());
this._proxy.$registerSourceControl(this.handle, _id, _label, _rootUri);
}

private updatedResourceGroups = new Set<ExtHostSourceControlResourceGroup>();
Expand Down Expand Up @@ -542,17 +542,17 @@ export class ExtHostSCM implements ExtHostSCMShape {
return inputBox;
}

$provideOriginalResource(sourceControlHandle: number, uriString: string): TPromise<string> {
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, uriString);
$provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents): TPromise<UriComponents> {
const uri = URI.revive(uriComponents);
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, uri.toString());

const sourceControl = this._sourceControls.get(sourceControlHandle);

if (!sourceControl || !sourceControl.quickDiffProvider) {
return TPromise.as(null);
}

return asWinJsPromise(token => sourceControl.quickDiffProvider.provideOriginalResource(URI.parse(uriString), token))
.then(result => result && result.toString());
return asWinJsPromise(token => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
}

$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> {
Expand Down

0 comments on commit 53df86a

Please sign in to comment.