Skip to content

Commit

Permalink
adding the behavior of using the current path for adding project, if …
Browse files Browse the repository at this point in the history
…non selected.
  • Loading branch information
toumorokoshi authored and Osmose committed Oct 4, 2017
1 parent 8749efb commit 028dcd1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
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;

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

0 comments on commit 028dcd1

Please sign in to comment.