Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for add-project-folder, use current path if non selected #149

Merged
merged 1 commit into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
- [AlexWayfer](https://github.com/AlexWayfer)
- [jacobmischka](https://github.com/jacobmischka)
- [lee-dohm](https://github.com/lee-dohm)
- [toumorokoshi](https://github.com/toumorokoshi)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Available commands for binding:

<dt><code>application:add-project-folder</code></dt>
<dd>
If a folder path has been selected with the cursor, add it as a project
directory.
If either a folder path has been selected with the cursor, or the current
path is a folder, add that path as a project directory.
</dd>

<dt><code>advanced-open-file:autocomplete</code></dt>
Expand Down
5 changes: 4 additions & 1 deletion lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ export class AdvancedOpenFileController {
event.stopPropagation();

let selectedPath = this.view.selectedPath();
if (selectedPath !== null && !selectedPath.equals(this.currentPath.parent())) {
if (selectedPath == null && this.currentPath.isDirectory()) {
this.addProjectFolder(this.currentPath.full);
}
else if (selectedPath !== null && !selectedPath.equals(this.currentPath.parent())) {
this.addProjectFolder(selectedPath.full);
} else {
atom.beep();
Expand Down
11 changes: 9 additions & 2 deletions spec/advanced-open-file-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ describe('Functional tests', () => {

it('can open files in new split panes', () => {
atom.workspace.open(fixturePath('sample.js'));
expect(atom.workspace.getPanes().length).toEqual(1);
const initialPaneCount = atom.workspace.getPanes().length;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test was failing for me, and I found using a relative pane count fixed it.


setPath(fixturePath('prefix_match.js'));
dispatch('pane:split-left');
Expand All @@ -603,7 +603,7 @@ describe('Functional tests', () => {
fixturePath('sample.js'),
fixturePath('prefix_match.js'),
]));
expect(atom.workspace.getPanes().length).toEqual(2);
expect(atom.workspace.getPanes().length).toEqual(initialPaneCount + 1);
});
});

Expand Down Expand Up @@ -730,6 +730,13 @@ describe('Functional tests', () => {
expect(atom.project.getPaths()).toEqual([fixturePath('examples')]);
});

it('will attempt to add the current path if no path if no path is selected', () => {
atom.project.setPaths([]);
setPath(fixturePath() + stdPath.sep);
dispatch('application:add-project-folder');
expect(atom.project.getPaths()).toEqual([fixturePath()]);
});

it('beeps when trying to add the parent folder as a project directory', () => {
spyOn(atom, 'beep');
atom.project.setPaths([]);
Expand Down