Skip to content

Commit

Permalink
🐛 expect resources, not uris in commands
Browse files Browse the repository at this point in the history
fixes #23689
  • Loading branch information
joaomoreno committed Mar 30, 2017
1 parent 817174b commit 521fdc2
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,7 @@ export class CommandCenter {
}

@command('git.openFile')
async openFile(uri?: Uri): Promise<void> {
if (uri && uri.scheme === 'file') {
return await commands.executeCommand<void>('vscode.open', uri);
}

const resource = this.resolveSCMResource(uri);

async openFile(resource?: Resource): Promise<void> {
if (!resource) {
return;
}
Expand All @@ -259,9 +253,7 @@ export class CommandCenter {
}

@command('git.openChange')
async openChange(uri?: Uri): Promise<void> {
const resource = this.resolveSCMResource(uri);

async openChange(resource?: Resource): Promise<void> {
if (!resource) {
return;
}
Expand All @@ -272,7 +264,7 @@ export class CommandCenter {
@command('git.stage')
async stage(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) {
const resource = this.resolveSCMResource();
const resource = this.getActiveEditorSCMResource();

if (!resource) {
return;
Expand Down Expand Up @@ -378,7 +370,7 @@ export class CommandCenter {
@command('git.unstage')
async unstage(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) {
const resource = this.resolveSCMResource();
const resource = this.getActiveEditorSCMResource();

if (!resource) {
return;
Expand Down Expand Up @@ -446,7 +438,7 @@ export class CommandCenter {
@command('git.clean')
async clean(...resourceStates: SourceControlResourceState[]): Promise<void> {
if (resourceStates.length === 0) {
const resource = this.resolveSCMResource();
const resource = this.getActiveEditorSCMResource();

if (!resource) {
return;
Expand Down Expand Up @@ -799,8 +791,8 @@ export class CommandCenter {
return result;
}

private resolveSCMResource(uri?: Uri): Resource | undefined {
uri = uri || window.activeTextEditor && window.activeTextEditor.document.uri;
private getActiveEditorSCMResource(): Resource | undefined {
let uri = window.activeTextEditor && window.activeTextEditor.document.uri;

if (!uri) {
return undefined;
Expand Down

0 comments on commit 521fdc2

Please sign in to comment.