Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
New File and New Folder execute in project root if there's no selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Gerber committed Jun 13, 2017
1 parent b9c5795 commit fb2f430
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ define(function (require, exports, module) {
// (Note: 'selected' may be an item that's selected in the workingset and not the tree; but in that case
// ProjectManager.createNewItem() ignores the baseDir we give it and falls back to the project root on its own)
var baseDirEntry,
selected = ProjectManager.getSelectedItem();
selected = ProjectManager.getSelectedItem(false);
if ((!selected) || (selected instanceof InMemoryFile)) {
selected = ProjectManager.getProjectRoot();
}
Expand Down
9 changes: 7 additions & 2 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,20 @@ define(function (require, exports, module) {
* the file tree OR in the working set; or null if no item is selected anywhere in the sidebar.
* May NOT be identical to the current Document - a folder may be selected in the sidebar, or the sidebar may not
* have the current document visible in the tree & working set.
* @param {boolean=} includeWorkingSet If true, fall back to the working set item that is selected if there's
* no selected file tree item (default behaviour)
* @return {?(File|Directory)}
*/
function getSelectedItem() {
function getSelectedItem(includeWorkingSet) {
if (includeWorkingSet === undefined) {
includeWorkingSet = true;
}
// Prefer file tree context, then selection, else use working set
var selectedEntry = model.getContext();
if (!selectedEntry) {
selectedEntry = model.getSelected();
}
if (!selectedEntry) {
if (!selectedEntry && includeWorkingSet) {
selectedEntry = MainViewManager.getCurrentlyViewedFile();
}
return selectedEntry;
Expand Down

0 comments on commit fb2f430

Please sign in to comment.