Skip to content

Commit a90d7c2

Browse files
committed
Merge pull request adobe#1290 from adobe/tvoliter/issue-1280
Correctly handle focus changes between working set and file tree when activating document from find in filesfixes adobe#1280
2 parents c5e28e0 + 6f3d70b commit a90d7c2

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/project/FileViewController.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ define(function (require, exports, module) {
114114
* in the working set (the open files) or in the file tree, but not both.
115115
* @param {String} fileSelectionFocus - either PROJECT_MANAGER or WORKING_SET_VIEW
116116
*/
117-
function setFileSelectionFocus(fileSelectionFocus) {
117+
function setFileViewFocus(fileSelectionFocus) {
118118
if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) {
119-
throw new Error("Bad parameter passed to FileViewController.setFileSelectionFocus");
119+
throw new Error("Bad parameter passed to FileViewController.setFileViewFocus");
120120
}
121121

122122
_fileSelectionFocus = fileSelectionFocus;
123-
$(exports).triggerHandler("documentSelectionFocusChange");
123+
$(exports).triggerHandler("fileViewFocusChange");
124124
}
125125

126126
/**
@@ -206,7 +206,7 @@ define(function (require, exports, module) {
206206
exports.getFileSelectionFocus = getFileSelectionFocus;
207207
exports.openAndSelectDocument = openAndSelectDocument;
208208
exports.addToWorkingSetAndSelect = addToWorkingSetAndSelect;
209-
exports.setFileSelectionFocus = setFileSelectionFocus;
209+
exports.setFileViewFocus = setFileViewFocus;
210210
exports.WORKING_SET_VIEW = WORKING_SET_VIEW;
211211
exports.PROJECT_MANAGER = PROJECT_MANAGER;
212212
});

src/project/ProjectManager.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,14 @@ define(function (require, exports, module) {
163163
}
164164
return null;
165165
}
166+
167+
function _fileViewFocusChange() {
168+
_redraw(true);
169+
}
166170

167-
var _documentSelectionFocusChange = function () {
171+
function _documentSelectionFocusChange() {
168172
var curDoc = DocumentManager.getCurrentDocument();
169173
if (curDoc && _hasFileSelectionFocus()) {
170-
171-
// Don't update the file tree selection to the current open doc when there is a directory
172-
// already selected
173-
var selected = getSelectedItem();
174-
if (selected && selected.isDirectory) {
175-
return;
176-
}
177-
178174
$("#project-files-container li").is(function (index) {
179175
var entry = $(this).data("entry");
180176
if (entry && entry.fullPath === curDoc.file.fullPath && !_projectTree.jstree("is_selected", $(this))) {
@@ -192,7 +188,7 @@ define(function (require, exports, module) {
192188
}
193189

194190
_redraw(true);
195-
};
191+
}
196192

197193
/**
198194
* 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) {
375371
}
376372
});
377373
} else {
378-
FileViewController.setFileSelectionFocus(FileViewController.PROJECT_MANAGER);
374+
FileViewController.setFileViewFocus(FileViewController.PROJECT_MANAGER);
379375
// show selection marker on folders
380376
_redraw(true);
381377

@@ -953,6 +949,7 @@ define(function (require, exports, module) {
953949

954950
// Event Handlers
955951
$(FileViewController).on("documentSelectionFocusChange", _documentSelectionFocusChange);
952+
$(FileViewController).on("fileViewFocusChange", _fileViewFocusChange);
956953
$("#open-files-container").on("contentChanged", function () {
957954
_redraw(false); // redraw jstree when working set size changes
958955
});

src/project/WorkingSetView.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
/**
2929
* WorkingSetView generates the UI for the list of the files user is editing based on the model provided by EditorManager.
3030
* The UI allows the user to see what files are open/dirty and allows them to close files and specify the current editor.
31+
*
32+
* Events dispatched:
33+
* documentSelectionFocusChange - indicates a document change has caused the focus to change between the working
34+
* set and file tree.
35+
* fileViewFocusChange - indicates the selection focus has changed between the working set and the project tree, but the
36+
* document selection has NOT changed
3137
*/
3238
define(function (require, exports, module) {
3339
"use strict";
@@ -286,6 +292,7 @@ define(function (require, exports, module) {
286292
*/
287293
function _handleDocumentSelectionChange() {
288294
_updateListSelection();
295+
_fireSelectionChanged();
289296
}
290297

291298
/**
@@ -351,10 +358,7 @@ define(function (require, exports, module) {
351358
_handleDirtyFlagChanged(doc);
352359
});
353360

354-
$(FileViewController).on("documentSelectionFocusChange", function (event, eventTarget) {
355-
_handleDocumentSelectionChange();
356-
_fireSelectionChanged();
357-
});
361+
$(FileViewController).on("documentSelectionFocusChange fileViewFocusChange", _handleDocumentSelectionChange )
358362

359363
// Show scroller shadows when open-files-container scrolls
360364
ViewUtils.addScrollerShadow($openFilesContainer[0], null, true);

0 commit comments

Comments
 (0)