diff --git a/AUTHORS.md b/AUTHORS.md index e529508..df2b71b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -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) diff --git a/README.md b/README.md index bda5d11..ab33dfb 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,8 @@ Available commands for binding:
application:add-project-folder
- 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.
advanced-open-file:autocomplete
diff --git a/lib/controller.js b/lib/controller.js index 3d2b62d..d65d575 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -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(); diff --git a/spec/advanced-open-file-spec.js b/spec/advanced-open-file-spec.js index 8d853a4..279aad4 100644 --- a/spec/advanced-open-file-spec.js +++ b/spec/advanced-open-file-spec.js @@ -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'); @@ -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); }); }); @@ -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([]);