Skip to content

Commit

Permalink
Multi-root support (fixes microsoft#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti authored and kieferrm committed Apr 2, 2018
1 parent 108e35e commit 49687cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"url": "https://github.com/Microsoft/vscode-github-issues-prs/issues"
},
"engines": {
"vscode": "^1.13.0"
"vscode": "^1.16.0"
},
"categories": [
"Other"
Expand Down Expand Up @@ -168,4 +168,4 @@
"request":"^2.81.0",
"open": "0.0.5"
}
}
}
30 changes: 17 additions & 13 deletions src/github-issues-prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,28 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
private username: string | undefined;

constructor(private context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.refresh', this.refresh, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.createIssue', this.createIssue, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.openIssue', this.openIssue, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.openPullRequest', this.openIssue, this));
// context.subscriptions.push(commands.registerCommand('githubIssuesPrs.checkoutPullRequest', this.checkoutPullRequest, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.copyNumber', this.copyNumber, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.copyText', this.copyText, this));
context.subscriptions.push(commands.registerCommand('githubIssuesPrs.copyMarkdown', this.copyMarkdown, this));

context.subscriptions.push(window.onDidChangeActiveTextEditor(this.poll, this));
const subscriptions = context.subscriptions;
subscriptions.push(commands.registerCommand('githubIssuesPrs.refresh', this.refresh, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.createIssue', this.createIssue, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.openIssue', this.openIssue, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.openPullRequest', this.openIssue, this));
// subscriptions.push(commands.registerCommand('githubIssuesPrs.checkoutPullRequest', this.checkoutPullRequest, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.copyNumber', this.copyNumber, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.copyText', this.copyText, this));
subscriptions.push(commands.registerCommand('githubIssuesPrs.copyMarkdown', this.copyMarkdown, this));

subscriptions.push(window.onDidChangeActiveTextEditor(this.poll, this));

this.username = workspace.getConfiguration('github').get<string>('username');
context.subscriptions.push(workspace.onDidChangeConfiguration(() => {
subscriptions.push(workspace.onDidChangeConfiguration(() => {
const newUsername = workspace.getConfiguration('github').get<string>('username');
if (newUsername !== this.username) {
this.username = newUsername;
this.refresh();
}
}));

subscriptions.push(workspace.onDidChangeWorkspaceFolders(this.refresh, this));
}

getTreeItem(element: TreeItem): TreeItem {
Expand Down Expand Up @@ -162,7 +165,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
}

private async fetchChildren(element?: TreeItem): Promise<TreeItem[]> {
if (!workspace.rootPath) {
if (!workspace.workspaceFolders) {
return [new TreeItem('No folder opened')];
}

Expand Down Expand Up @@ -270,6 +273,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
}

/* private */ async checkoutPullRequest(issue: Issue) {
// TODO: Move off rootPath
const github = new GitHub();
const p = Uri.parse(issue.item.repository_url).path;
const repo = path.basename(p);
Expand Down Expand Up @@ -337,5 +341,5 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
}


// none-sense comment
// none-sense comment again
}

0 comments on commit 49687cc

Please sign in to comment.