Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Implement using active panel to determine active project
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlyons0 committed Jan 19, 2020
1 parent 6d10136 commit 08aef18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/github-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default class GithubPackage {
this.confirm = confirm;
this.startOpen = false;
this.activated = false;
this.projectFromActivePanel = false;

const criteria = {
projectPathCount: this.project.getPaths().length,
Expand Down Expand Up @@ -181,8 +182,26 @@ export default class GithubPackage {
this.scheduleActiveContextUpdate({activeRepositoryPath});
};

const handleActivePaneChange = item => {
if (!this.projectFromActivePanel || !item || !item.buffer || !item.buffer.file || !item.buffer.file.path) {
return;
}

const activeDirectory = this.project.getDirectories().find(directory => {
return directory.contains(item.buffer.file.path);
});
const activeRepositoryPath = activeDirectory ? activeDirectory.getPath() : undefined;
this.scheduleActiveContextUpdate({activeRepositoryPath}, {item});
};

const handleUseProjectFromActivePanelChange = newValue => {
this.projectFromActivePanel = newValue;
};

this.subscriptions.add(
this.project.onDidChangePaths(handleProjectPathsChange),
this.workspace.getCenter().onDidStopChangingActivePaneItem(handleActivePaneChange),
this.config.observe('github.useProjectFromActivePanel', handleUseProjectFromActivePanelChange),
this.styleCalculator.startWatching(
'github-package-styles',
['editor.fontSize', 'editor.fontFamily', 'editor.lineHeight', 'editor.tabLength'],
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@
"ssh"
],
"description": "Transport protocol to prefer when creating a new git remote"
},
"useProjectFromActivePanel": {
"type": "boolean",
"default": false,
"description": "Use active panel to determine which project to show"
}
},
"deserializers": {
Expand Down

0 comments on commit 08aef18

Please sign in to comment.