This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Project panel bug fixes #845
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8c3f0ff
Refactor sidebar resize to SidebarView. Fix editor shadow width. Fix …
jasonsanjose 2b7678b
Revert initial refactor of ProjectView. Do not fire selectionChanged …
jasonsanjose 6206c7c
Restore selection on a file when reopening an ancestor folder.
jasonsanjose 1293674
Add dblclick to toggle. Fix triangle visibility when snapping.
jasonsanjose 7d9e1d5
Code review comments. Fixes selection marker when closing jstree nodes
jasonsanjose bddd5cf
Merge branch 'refs/heads/master' into jason-sanjose/issue800
jasonsanjose 50ba90d
Use updated hyphenated names
jasonsanjose 56f8035
Increase sidebar resizer width. Fix dblclick bugs.
jasonsanjose e1f6122
Fix scroller shadow resize
jasonsanjose 5c4f962
Don't resize shadow when using absolute positioning.
jasonsanjose 41fc773
fix merge issues
jasonsanjose a0b2f6d
Cleanup sidebar resizer. Fix edge case when moving from snapped close…
jasonsanjose 7dec20d
Merge branch 'refs/heads/master' into jason-sanjose/issue800
jasonsanjose 2920abe
fix comment for _setWidth
jasonsanjose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,13 @@ define(function (require, exports, module) { | |
ViewUtils = require("utils/ViewUtils"), | ||
FileUtils = require("file/FileUtils"); | ||
|
||
/** | ||
* @private | ||
* Reference to the tree control container div | ||
* @type {jQueryObject} | ||
*/ | ||
var $projectTreeContainer = $("#project-files-container"); | ||
|
||
/** | ||
* @private | ||
* Reference to the tree control | ||
|
@@ -65,11 +72,19 @@ define(function (require, exports, module) { | |
|
||
/** | ||
* @private | ||
* Reference to previous selectiooon jstree node | ||
* Reference to previous selected jstree leaf node when ProjectManager had | ||
* selection focus from FileViewController. | ||
* @type {DOMElement} | ||
*/ | ||
var _lastSelected = null; | ||
|
||
/** | ||
* @private | ||
* Intrnal flag to suppress firing of selectionChanged event. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo - "Intrnal" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
* @type {boolean} | ||
*/ | ||
var _suppressSelectionChange = false; | ||
|
||
/** | ||
* @private | ||
* Reference to the tree control UL element | ||
|
@@ -99,33 +114,27 @@ define(function (require, exports, module) { | |
fullPathToIdMap : {} /* mapping of fullPath to tree node id attr */ | ||
}; | ||
|
||
/** | ||
* @const | ||
* Sidebar open constant | ||
*/ | ||
var SIDEBAR_OPEN = "open"; | ||
|
||
/** | ||
* @const | ||
* Sidebar closed constant | ||
*/ | ||
var SIDEBAR_CLOSED = "closed"; | ||
|
||
/** | ||
/** | ||
* @private | ||
* Current state of sidebar | ||
*/ | ||
var _sidebarState = SIDEBAR_OPEN; | ||
|
||
|
||
function _hasFileSelectionFocus() { | ||
return FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER; | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
function _fireSelectionChanged() { | ||
function _redraw(selectionChanged, reveal) { | ||
reveal = (reveal === undefined) ? true : reveal; | ||
|
||
// redraw selection | ||
if ($projectTreeList) { | ||
$projectTreeList.trigger("selectionChanged"); | ||
if (selectionChanged && !_suppressSelectionChange) { | ||
$projectTreeList.triggerHandler("selectionChanged", reveal); | ||
} | ||
|
||
// reposition the selection triangle | ||
$projectTreeContainer.triggerHandler("scroll"); | ||
|
||
// in-lieu of resize events, manually trigger contentChanged for every | ||
// FileViewController focus change. This event triggers scroll shadows | ||
|
@@ -137,8 +146,7 @@ define(function (require, exports, module) { | |
|
||
var _documentSelectionFocusChange = function () { | ||
var curDoc = DocumentManager.getCurrentDocument(); | ||
if (curDoc | ||
&& (FileViewController.getFileSelectionFocus() !== FileViewController.WORKING_SET_VIEW)) { | ||
if (curDoc && _hasFileSelectionFocus()) { | ||
$("#project-files-container li").is(function (index) { | ||
var entry = $(this).data("entry"); | ||
|
||
|
@@ -156,7 +164,7 @@ define(function (require, exports, module) { | |
_lastSelected = null; | ||
} | ||
|
||
_fireSelectionChanged(); | ||
_redraw(true); | ||
}; | ||
|
||
/** | ||
|
@@ -238,6 +246,25 @@ define(function (require, exports, module) { | |
|
||
_prefs.setAllValues(storage); | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
function _forceSelection(current, target) { | ||
// select_node will force the target to be revealed. Instead, | ||
// keep the scroller position stable. | ||
var savedScrollTop = $projectTreeContainer.get(0).scrollTop; | ||
|
||
// suppress selectionChanged event from firing by jstree select_node | ||
_suppressSelectionChange = true; | ||
_projectTree.jstree("deselect_node", current); | ||
_projectTree.jstree("select_node", target, false); | ||
_suppressSelectionChange = false; | ||
|
||
$projectTreeContainer.get(0).scrollTop = savedScrollTop; | ||
|
||
_redraw(true, false); | ||
} | ||
|
||
/** | ||
* @private | ||
|
@@ -247,8 +274,7 @@ define(function (require, exports, module) { | |
* http://www.jstree.com/documentation/json_data | ||
*/ | ||
function _renderTree(treeDataProvider) { | ||
var $projectTreeContainer = $("#project-files-container"), | ||
result = new $.Deferred(); | ||
var result = new $.Deferred(); | ||
|
||
// Instantiate tree widget | ||
// (jsTree is smart enough to replace the old tree if there's already one there) | ||
|
@@ -280,24 +306,23 @@ define(function (require, exports, module) { | |
function (event, data) { | ||
var entry = data.rslt.obj.data("entry"); | ||
if (entry.isFile) { | ||
var openResult = FileViewController.openAndSelectDocument(entry.fullPath, "ProjectManager"); | ||
var openResult = FileViewController.openAndSelectDocument(entry.fullPath, FileViewController.PROJECT_MANAGER); | ||
|
||
openResult.done(function () { | ||
// update when tree display state changes | ||
_fireSelectionChanged(); | ||
_redraw(true); | ||
_lastSelected = data.rslt.obj; | ||
}).fail(function () { | ||
if (_lastSelected) { | ||
// revert this new selection and restore previous selection | ||
_projectTree.jstree("deselect_node", data.rslt.obj); | ||
_projectTree.jstree("select_node", _lastSelected, false); | ||
_forceSelection(data.rslt.obj, _lastSelected); | ||
} else { | ||
_projectTree.jstree("deselect_all"); | ||
_lastSelected = null; | ||
} | ||
}); | ||
} else { | ||
_fireSelectionChanged(); | ||
_redraw(true); | ||
} | ||
} | ||
) | ||
|
@@ -335,10 +360,22 @@ define(function (require, exports, module) { | |
.bind( | ||
"loaded.jstree open_node.jstree close_node.jstree", | ||
function (event, data) { | ||
ViewUtils.updateChildrenToParentScrollwidth($("#project-files-container")); | ||
|
||
// update when tree display state changes | ||
_fireSelectionChanged(); | ||
// select the current document if it becomes visible when this folder is opened | ||
if (event.type === "open_node") { | ||
var curDoc = DocumentManager.getCurrentDocument(); | ||
|
||
if (_hasFileSelectionFocus() && curDoc) { | ||
var entry = data.rslt.obj.data("entry"); | ||
|
||
if (curDoc.file.fullPath.indexOf(entry.fullPath) === 0) { | ||
_forceSelection(data.rslt.obj, _lastSelected); | ||
} | ||
} | ||
} | ||
|
||
_redraw(false); | ||
|
||
_savePreferences(); | ||
} | ||
); | ||
|
@@ -545,9 +582,6 @@ define(function (require, exports, module) { | |
// Success! | ||
_projectRoot = rootEntry; | ||
|
||
// Set title | ||
$("#project-title").html(_projectRoot.name); | ||
|
||
// The tree will invoke our "data provider" function to populate the top-level items, then | ||
// go idle until a node is expanded - at which time it'll call us again to fetch the node's | ||
// immediate children, and so on. | ||
|
@@ -807,23 +841,6 @@ define(function (require, exports, module) { | |
function forceFinishRename() { | ||
$(".jstree-rename-input").blur(); | ||
} | ||
|
||
/***** Start of Sidebar methods ******/ | ||
|
||
/** | ||
* Gets the current state of the sidebar | ||
*/ | ||
function getSidebarState() { | ||
return _sidebarState; | ||
} | ||
|
||
/** | ||
* Sets the sidebar state when something happens | ||
* @param newState {string} new state for sidebar | ||
*/ | ||
function setSidebarState(newState) { | ||
_sidebarState = newState; | ||
} | ||
|
||
// Define public API | ||
exports.getProjectRoot = getProjectRoot; | ||
|
@@ -834,10 +851,6 @@ define(function (require, exports, module) { | |
exports.getSelectedItem = getSelectedItem; | ||
exports.createNewItem = createNewItem; | ||
exports.forceFinishRename = forceFinishRename; | ||
exports.SIDEBAR_OPEN = SIDEBAR_OPEN; | ||
exports.SIDEBAR_CLOSED = SIDEBAR_CLOSED; | ||
exports.getSidebarState = getSidebarState; | ||
exports.setSidebarState = setSidebarState; | ||
|
||
// Initialize now | ||
(function () { | ||
|
@@ -851,7 +864,9 @@ define(function (require, exports, module) { | |
|
||
// Event Handlers | ||
$(FileViewController).on("documentSelectionFocusChange", _documentSelectionFocusChange); | ||
$("#open-files-container").on("contentChanged", _fireSelectionChanged); // redraw jstree when working set size changes | ||
$("#open-files-container").on("contentChanged", function () { | ||
_redraw(false); // redraw jstree when working set size changes | ||
}); | ||
|
||
CommandManager.register(Commands.FILE_OPEN_FOLDER, openProject); | ||
}()); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're fixing one, you might as well fix them all :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done