diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index 33f51b5bcbf..05e16fad8c1 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -114,13 +114,13 @@ define(function (require, exports, module) { * in the working set (the open files) or in the file tree, but not both. * @param {String} fileSelectionFocus - either PROJECT_MANAGER or WORKING_SET_VIEW */ - function setFileSelectionFocus(fileSelectionFocus) { + function setFileViewFocus(fileSelectionFocus) { if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) { - throw new Error("Bad parameter passed to FileViewController.setFileSelectionFocus"); + throw new Error("Bad parameter passed to FileViewController.setFileViewFocus"); } _fileSelectionFocus = fileSelectionFocus; - $(exports).triggerHandler("documentSelectionFocusChange"); + $(exports).triggerHandler("fileViewFocusChange"); } /** @@ -206,7 +206,7 @@ define(function (require, exports, module) { exports.getFileSelectionFocus = getFileSelectionFocus; exports.openAndSelectDocument = openAndSelectDocument; exports.addToWorkingSetAndSelect = addToWorkingSetAndSelect; - exports.setFileSelectionFocus = setFileSelectionFocus; + exports.setFileViewFocus = setFileViewFocus; exports.WORKING_SET_VIEW = WORKING_SET_VIEW; exports.PROJECT_MANAGER = PROJECT_MANAGER; }); diff --git a/src/project/ProjectManager.js b/src/project/ProjectManager.js index 003f30c0f7f..f3abe6dae15 100644 --- a/src/project/ProjectManager.js +++ b/src/project/ProjectManager.js @@ -163,18 +163,14 @@ define(function (require, exports, module) { } return null; } + + function _fileViewFocusChange() { + _redraw(true); + } - var _documentSelectionFocusChange = function () { + function _documentSelectionFocusChange() { var curDoc = DocumentManager.getCurrentDocument(); if (curDoc && _hasFileSelectionFocus()) { - - // Don't update the file tree selection to the current open doc when there is a directory - // already selected - var selected = getSelectedItem(); - if (selected && selected.isDirectory) { - return; - } - $("#project-files-container li").is(function (index) { var entry = $(this).data("entry"); if (entry && entry.fullPath === curDoc.file.fullPath && !_projectTree.jstree("is_selected", $(this))) { @@ -192,7 +188,7 @@ define(function (require, exports, module) { } _redraw(true); - }; + } /** * Returns the root folder of the currently loaded project, or null if no project is open (during @@ -375,7 +371,7 @@ define(function (require, exports, module) { } }); } else { - FileViewController.setFileSelectionFocus(FileViewController.PROJECT_MANAGER); + FileViewController.setFileViewFocus(FileViewController.PROJECT_MANAGER); // show selection marker on folders _redraw(true); @@ -953,6 +949,7 @@ define(function (require, exports, module) { // Event Handlers $(FileViewController).on("documentSelectionFocusChange", _documentSelectionFocusChange); + $(FileViewController).on("fileViewFocusChange", _fileViewFocusChange); $("#open-files-container").on("contentChanged", function () { _redraw(false); // redraw jstree when working set size changes }); diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 438d5ad806f..4d0703a709b 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -28,6 +28,12 @@ /** * WorkingSetView generates the UI for the list of the files user is editing based on the model provided by EditorManager. * The UI allows the user to see what files are open/dirty and allows them to close files and specify the current editor. + * + * Events dispatched: + * documentSelectionFocusChange - indicates a document change has caused the focus to change between the working + * set and file tree. + * fileViewFocusChange - indicates the selection focus has changed between the working set and the project tree, but the + * document selection has NOT changed */ define(function (require, exports, module) { "use strict"; @@ -286,6 +292,7 @@ define(function (require, exports, module) { */ function _handleDocumentSelectionChange() { _updateListSelection(); + _fireSelectionChanged(); } /** @@ -351,10 +358,7 @@ define(function (require, exports, module) { _handleDirtyFlagChanged(doc); }); - $(FileViewController).on("documentSelectionFocusChange", function (event, eventTarget) { - _handleDocumentSelectionChange(); - _fireSelectionChanged(); - }); + $(FileViewController).on("documentSelectionFocusChange fileViewFocusChange", _handleDocumentSelectionChange ) // Show scroller shadows when open-files-container scrolls ViewUtils.addScrollerShadow($openFilesContainer[0], null, true);