-
Notifications
You must be signed in to change notification settings - Fork 7.6k
fix some working set view issues #9134
Changes from 4 commits
4e2b40c
6b511cd
2211499
9ee3a2a
9433ad8
eba535c
fb2b075
4df265e
eefe6b3
2ecef07
48f6486
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,7 +272,7 @@ define(function (require, exports, module) { | |
WorkingSetView.prototype._checkForDuplicatesInWorkingTree = function () { | ||
var self = this, | ||
map = {}, | ||
fileList = MainViewManager.getWorkingSet(this.paneId); | ||
fileList = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES); | ||
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. don't limit the search to just the current pane's working set. search them all... |
||
|
||
// We need to always clear current directories as files could be removed from working tree. | ||
this.$openFilesContainer.find("ul > li > a > span.directory").remove(); | ||
|
@@ -305,8 +305,10 @@ define(function (require, exports, module) { | |
|
||
if (paneId === this.paneId) { | ||
this.$el.addClass("active"); | ||
this.$openFilesContainer.addClass("active"); | ||
} else { | ||
this.$el.removeClass("active"); | ||
this.$openFilesContainer.removeClass("active"); | ||
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. Adding and removing the |
||
} | ||
|
||
this._updateVisibility(); | ||
|
@@ -650,6 +652,8 @@ define(function (require, exports, module) { | |
WorkingSetView.prototype._handleFileAdded = function (e, fileAdded, index, paneId) { | ||
if (paneId === this.paneId) { | ||
this._rebuildViewList(true); | ||
} else { | ||
this._checkForDuplicatesInWorkingTree(); | ||
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. these calls to |
||
} | ||
}; | ||
|
||
|
@@ -663,6 +667,8 @@ define(function (require, exports, module) { | |
WorkingSetView.prototype._handleFileListAdded = function (e, files, paneId) { | ||
if (paneId === this.paneId) { | ||
this._rebuildViewList(true); | ||
} else { | ||
this._checkForDuplicatesInWorkingTree(); | ||
} | ||
}; | ||
|
||
|
@@ -690,6 +696,8 @@ define(function (require, exports, module) { | |
} | ||
|
||
this._redraw(); | ||
} else { | ||
this._checkForDuplicatesInWorkingTree(); | ||
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. The I'm wondering if 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. Looks like we want to ignore if (paneId === this.paneId) {
if (!suppressRedraw) {
// snip...
}
} else {
this._checkForDuplicatesInWorkingTree();
} 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. Keep in mind that there are 2 working set views... The suppress redraw flag is only affecting the one that's being updated which won't check for duplicates when the This is used in 2 cases:
The pane that isn't affected by the change, however, is free to draw when it needs to with check for duplicates. The other thing to keep in mind is that when using the 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. That's a great explanation that belongs in the code somewhere! |
||
} | ||
}; | ||
|
||
|
@@ -711,6 +719,8 @@ define(function (require, exports, module) { | |
}); | ||
|
||
this._redraw(); | ||
} else { | ||
this._checkForDuplicatesInWorkingTree(); | ||
} | ||
}; | ||
|
||
|
@@ -749,6 +759,8 @@ define(function (require, exports, module) { | |
WorkingSetView.prototype._handleWorkingSetUpdate = function (e, paneId) { | ||
if (this.paneId === paneId) { | ||
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. also check for rename and delete. |
||
this._rebuildViewList(true); | ||
} else { | ||
this._checkForDuplicatesInWorkingTree(); | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ define(function (require, exports, module) { | |
ViewUtils = require("utils/ViewUtils"), | ||
Resizer = require("utils/Resizer"), | ||
Pane = require("view/Pane").Pane; | ||
|
||
/** | ||
* Preference setting name for the MainView Saved State | ||
* @const | ||
|
@@ -954,6 +954,16 @@ define(function (require, exports, module) { | |
}); | ||
} | ||
|
||
/** | ||
* Updates the header text for all panes | ||
*/ | ||
function _updatePaneHeaders() { | ||
_forEachPaneOrPanes(ALL_PANES, function (pane) { | ||
pane.updateHeaderText(); | ||
}); | ||
|
||
} | ||
|
||
/** | ||
* Creates a pane for paneId if one doesn't already exist | ||
* @param {!string} paneId - id of the pane to create | ||
|
@@ -975,9 +985,11 @@ define(function (require, exports, module) { | |
}); | ||
|
||
$(pane).on("viewListChange.mainview", function () { | ||
_updatePaneHeaders(); | ||
$(exports).triggerHandler("workingSetUpdate", [pane.id]); | ||
}); | ||
$(pane).on("currentViewChange.mainview", function (e, newView, oldView) { | ||
_updatePaneHeaders(); | ||
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. Updating the titles here will ensure that "Temporary" views and duplicates thereof are given a qualified name too. |
||
if (_activePaneId === pane.id) { | ||
$(exports).triggerHandler("currentFileChange", | ||
[newView && newView.getFile(), | ||
|
@@ -1516,7 +1528,7 @@ define(function (require, exports, module) { | |
return result; | ||
} | ||
|
||
/** | ||
/** | ||
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. @JeffryBooher Why did you add a space at end of comment open delimiter here? I cleaned up a bunch of those in another PR. 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. i'm pretty sure that brackets did this on its own :) Looks like it did something similar on line 97. 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. I've never seen this in any other code review. Maybe an extension? Maybe a recently introduced bug? |
||
* Setup a ready event to initialize ourself | ||
*/ | ||
AppInit.htmlReady(function () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,7 @@ define(function (require, exports, module) { | |
Commands = require("command/Commands"), | ||
Strings = require("strings"), | ||
ViewUtils = require("utils/ViewUtils"), | ||
ProjectManager = require("project/ProjectManager"), | ||
paneTemplate = require("text!htmlContent/pane.html"); | ||
|
||
|
||
|
@@ -238,12 +239,17 @@ define(function (require, exports, module) { | |
} | ||
}); | ||
|
||
this._updateHeaderText(); | ||
this.updateHeaderText(); | ||
|
||
// Listen to document events so we can update ourself | ||
$(DocumentManager).on(this._makeEventName("fileNameChange"), _.bind(this._handleFileNameChange, this)); | ||
$(DocumentManager).on(this._makeEventName("pathDeleted"), _.bind(this._handleFileDeleted, this)); | ||
$(MainViewManager).on(this._makeEventName("activePaneChange"), _.bind(this._handleActivePaneChange, this)); | ||
$(MainViewManager).on(this._makeEventName("workingSetAdd"), _.bind(this.updateHeaderText, this)); | ||
$(MainViewManager).on(this._makeEventName("workingSetRemove"), _.bind(this.updateHeaderText, this)); | ||
$(MainViewManager).on(this._makeEventName("workingSetAddList"), _.bind(this.updateHeaderText, this)); | ||
$(MainViewManager).on(this._makeEventName("workingSetRemoveList"), _.bind(this.updateHeaderText, this)); | ||
|
||
} | ||
|
||
/** | ||
|
@@ -620,8 +626,13 @@ define(function (require, exports, module) { | |
return uniqueFileList; | ||
}; | ||
|
||
/** | ||
* Dispatches a currentViewChange event | ||
* @param {?View} newView - the view become the current view | ||
* @param {?View} oldView - the view being replaced | ||
*/ | ||
Pane.prototype._notifyCurrentViewChange = function (newView, oldView) { | ||
this._updateHeaderText(); | ||
this.updateHeaderText(); | ||
|
||
$(this).triggerHandler("currentViewChange", [newView, oldView]); | ||
}; | ||
|
@@ -742,10 +753,21 @@ define(function (require, exports, module) { | |
* Updates text in pane header | ||
* @private | ||
*/ | ||
Pane.prototype._updateHeaderText = function () { | ||
var file = this.getCurrentlyViewedFile(); | ||
Pane.prototype.updateHeaderText = function () { | ||
var file = this.getCurrentlyViewedFile(), | ||
files, | ||
displayName; | ||
|
||
if (file) { | ||
this.$header.text(file.name); | ||
files = MainViewManager.getAllOpenFiles().filter(function (item) { | ||
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. we only care about the currently displayed file so just filter the list to those matching the name of the current file |
||
return (item.name === file.name); | ||
}); | ||
if (files.length < 2) { | ||
this.$header.text(file.name); | ||
} else { | ||
displayName = ProjectManager.makeProjectRelativeIfPossible(file.fullPath); | ||
this.$header.text(displayName); | ||
} | ||
} else { | ||
this.$header.html(Strings.EMPTY_VIEW_HEADER); | ||
} | ||
|
@@ -774,7 +796,7 @@ define(function (require, exports, module) { | |
delete this._views[oldname]; | ||
} | ||
|
||
this._updateHeaderText(); | ||
this.updateHeaderText(); | ||
|
||
// dispatch the change event | ||
if (dispatchEvent) { | ||
|
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.
calling
_activatePane
here after setting_fileSelectionFocus
toWORKING_SET_VIEW
will trigger adocumentSelectionFocusChange
event which will tell the working set view to show the file in the selected state which fixes #9032.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.
this is what the old master did, btw.
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.
Fix for #9032 looks good except for 1 quirk with single select in project tree.
Split View, Open 4 files -- 2 in each working set
In project tree, single-click file that is open in current working set, but not displayed in editor.
Results:
File is selected in project tree. File is displayed in editor. This is same as 0.43
In project tree, single-click file in the other working set that is not displayed in editor.
Results:
File is selected in project tree. File is displayed in editor. This is same as 0.43
In project tree, single-click file in the other working set that is displayed in editor.
Results:
File is selected in working set.
Expected:
File is selected in project tree.
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.
this should be fixed now.
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.
I'm seeing that case 4 is fixed, but case 3 is now broken.
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.
hmmmm. this worked fine for me last night on the mac and it's working fine for me today on Windows.
#4 - single click file in other working set that IS displayed in editor
-> File is selected in project tree.
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.
@JeffryBooher Yes, 4 is now working for me, but 3 is no longer working.
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.
sorry, I was drawn to the "bold". The problem with #3 is the issue I fixed last night which is still working today for me. LMK after syncing to the latest branch
jeff/wsv-fixes
and we can look at it over connect.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.
It's fixed. I guess I didn't pull latest change.