Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
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
4 changes: 1 addition & 3 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,8 @@ define(function (require, exports, module) {
// If a file is currently selected in the tree, put it next to it.
// If a directory is currently selected in the tree, put it in it.
// If an Untitled document is selected or nothing is selected in the tree, put it at the root of the project.
// (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.getFileTreeContext();
if ((!selected) || (selected instanceof InMemoryFile)) {
selected = ProjectManager.getProjectRoot();
}
Expand Down
14 changes: 12 additions & 2 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,15 @@ define(function (require, exports, module) {
* Singleton actionCreator that is used for dispatching changes to the ProjectModel.
*/
var actionCreator = new ActionCreator(model);

/**
* Returns the File or Directory corresponding to the item that was right-clicked on in the file tree menu.
* @return {?(File|Directory)}
*/
function getFileTreeContext() {
var selectedEntry = model.getContext();
return selectedEntry;
}

/**
* Returns the File or Directory corresponding to the item selected in the sidebar panel, whether in
Expand All @@ -391,8 +400,8 @@ define(function (require, exports, module) {
* @return {?(File|Directory)}
*/
function getSelectedItem() {
// Prefer file tree context, then selection, else use working set
var selectedEntry = model.getContext();
// Prefer file tree context, then file tree selection, else use working set
var selectedEntry = getFileTreeContext();
if (!selectedEntry) {
selectedEntry = model.getSelected();
}
Expand Down Expand Up @@ -1396,6 +1405,7 @@ define(function (require, exports, module) {
exports.makeProjectRelativeIfPossible = makeProjectRelativeIfPossible;
exports.shouldShow = ProjectModel.shouldShow;
exports.openProject = openProject;
exports.getFileTreeContext = getFileTreeContext;
exports.getSelectedItem = getSelectedItem;
exports.getContext = getContext;
exports.getInitialProjectPath = getInitialProjectPath;
Expand Down