From 4e2b40c094289c73ec611d7f4bb452ea97c11c11 Mon Sep 17 00:00:00 2001 From: JeffryBooher Date: Tue, 16 Sep 2014 17:13:12 -0700 Subject: [PATCH 1/8] fix a couple of working set view issues --- src/project/WorkingSetView.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index b6e4ea84ac8..0e81cf0ed92 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -294,7 +294,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); // We need to always clear current directories as files could be removed from working tree. this.$openFilesContainer.find("ul > li > a > span.directory").remove(); @@ -328,8 +328,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"); } if (!fileList || fileList.length === 0) { @@ -681,6 +683,8 @@ define(function (require, exports, module) { WorkingSetView.prototype._handleFileAdded = function (e, fileAdded, index, paneId) { if (paneId === this.paneId) { this._rebuildViewList(true); + } else { + this._checkForDuplicatesInWorkingTree(); } }; @@ -694,6 +698,8 @@ define(function (require, exports, module) { WorkingSetView.prototype._handleFileListAdded = function (e, files, paneId) { if (paneId === this.paneId) { this._rebuildViewList(true); + } else { + this._checkForDuplicatesInWorkingTree(); } }; @@ -721,6 +727,8 @@ define(function (require, exports, module) { } this._redraw(); + } else { + this._checkForDuplicatesInWorkingTree(); } }; @@ -742,6 +750,8 @@ define(function (require, exports, module) { }); this._redraw(); + } else { + this._checkForDuplicatesInWorkingTree(); } }; @@ -780,6 +790,8 @@ define(function (require, exports, module) { WorkingSetView.prototype._handleWorkingSetUpdate = function (e, paneId) { if (this.paneId === paneId) { this._rebuildViewList(true); + } else { + this._checkForDuplicatesInWorkingTree(); } }; From 6b511cdae8c5d96e85f1aa32468d2d9f6d7118c7 Mon Sep 17 00:00:00 2001 From: JeffryBooher Date: Tue, 16 Sep 2014 23:36:45 -0700 Subject: [PATCH 2/8] fix 2 more issues --- src/project/FileViewController.js | 3 +++ src/view/MainViewManager.js | 9 +++++++++ src/view/Pane.js | 21 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index 99d34130050..2978ed81956 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -200,6 +200,9 @@ define(function (require, exports, module) { // image file, we get a null doc here but we still want to keep _fileSelectionFocus // as PROJECT_MANAGER. Regardless of doc is null or not, call _activatePane // to trigger documentSelectionFocusChange event. + _fileSelectionFocus = WORKING_SET_VIEW; + _activatePane(paneId); + result.resolve(file); }).fail(function (err) { result.reject(err); diff --git a/src/view/MainViewManager.js b/src/view/MainViewManager.js index 958ac9bfe1f..c113d99a35e 100644 --- a/src/view/MainViewManager.js +++ b/src/view/MainViewManager.js @@ -994,6 +994,13 @@ define(function (require, exports, module) { _cmdSplitHorizontally.setChecked(_orientation === HORIZONTAL); } + 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 @@ -1015,9 +1022,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(); if (_activePaneId === pane.id) { $(exports).triggerHandler("currentFileChange", [newView && newView.getFile(), diff --git a/src/view/Pane.js b/src/view/Pane.js index 560ffdd2093..bd5c986d14a 100644 --- a/src/view/Pane.js +++ b/src/view/Pane.js @@ -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"); @@ -244,6 +245,11 @@ define(function (require, exports, module) { $(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)); + } /** @@ -732,9 +738,20 @@ define(function (require, exports, module) { * @private */ Pane.prototype._updateHeaderText = function () { - var file = this.getCurrentlyViewedFile(); + var file = this.getCurrentlyViewedFile(), + files, + displayName; + if (file) { - this.$header.text(file.name); + files = MainViewManager.getAllOpenFiles().filter(function (item) { + 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); } From 2211499b0ac7cc14d4648e69b653f4fffd6aff6d Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Wed, 17 Sep 2014 00:01:28 -0700 Subject: [PATCH 3/8] fix rte --- src/view/MainViewManager.js | 3 +++ src/view/Pane.js | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/view/MainViewManager.js b/src/view/MainViewManager.js index c113d99a35e..819389a524d 100644 --- a/src/view/MainViewManager.js +++ b/src/view/MainViewManager.js @@ -994,6 +994,9 @@ define(function (require, exports, module) { _cmdSplitHorizontally.setChecked(_orientation === HORIZONTAL); } + /** + * Updates the header text for all panes + */ function _updatePaneHeaders() { _forEachPaneOrPanes(ALL_PANES, function (pane) { pane.updateHeaderText(); diff --git a/src/view/Pane.js b/src/view/Pane.js index bd5c986d14a..10e133b2ecc 100644 --- a/src/view/Pane.js +++ b/src/view/Pane.js @@ -239,16 +239,16 @@ 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)); + $(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)); } @@ -626,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]); }; @@ -737,7 +742,7 @@ define(function (require, exports, module) { * Updates text in pane header * @private */ - Pane.prototype._updateHeaderText = function () { + Pane.prototype.updateHeaderText = function () { var file = this.getCurrentlyViewedFile(), files, displayName; @@ -780,7 +785,7 @@ define(function (require, exports, module) { delete this._views[oldname]; } - this._updateHeaderText(); + this.updateHeaderText(); // dispatch the change event if (dispatchEvent) { From 9433ad840a5a19ba07b486b13d1e3d6c1c882ccd Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Wed, 17 Sep 2014 01:29:17 -0700 Subject: [PATCH 4/8] fix selector issue with selected item --- src/project/WorkingSetView.js | 32 +++++++++++++++++++++----------- src/styles/brackets.less | 29 +++++++++++------------------ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index f24d441d3d8..501f3cfd94c 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -301,16 +301,7 @@ define(function (require, exports, module) { * @private */ WorkingSetView.prototype._redraw = function () { - var paneId = MainViewManager.getActivePaneId(); - - if (paneId === this.paneId) { - this.$el.addClass("active"); - this.$openFilesContainer.addClass("active"); - } else { - this.$el.removeClass("active"); - this.$openFilesContainer.removeClass("active"); - } - + this._updateViewState(); this._updateVisibility(); this._adjustForScrollbars(); this._fireSelectionChanged(); @@ -624,13 +615,32 @@ define(function (require, exports, module) { } }; + /** + * Updates the pane view's selection state + * @private + */ + WorkingSetView.prototype._updateViewState = function () { + var paneId = MainViewManager.getActivePaneId(); + if ((FileViewController.getFileSelectionFocus() === FileViewController.WORKING_SET_VIEW) && + (paneId === this.paneId)) { + this.$el.addClass("active"); + this.$openFilesContainer.addClass("active"); + } else { + this.$el.removeClass("active"); + this.$openFilesContainer.removeClass("active"); + } + }; + /** * Updates the pane view's selection marker and scrolls the item into view * @private */ WorkingSetView.prototype._updateListSelection = function () { var file = MainViewManager.getCurrentlyViewedFile(this.paneId); - + + this._updateViewState(); + + // Iterate through working set list and update the selection on each var items = this.$openFilesContainer.find("ul").children().each(function () { _updateListItemSelection(this, file); diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 452442e0697..05463336868 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -767,13 +767,6 @@ a, img { padding: 0 0 0 8px; min-height: 18px; vertical-align: baseline; - - &.selected { - a, - .extension { - color: #99dbff; - } - } } a { @@ -804,18 +797,7 @@ a, img { } } -.open-files-container.active { - li { - &.selected a { - color: @open-working-file-name-highlight; - } - - &.selected .extension { - color: @open-working-file-ext-highlight; - } - } -} .sidebar-selection { background: @bc-sidebar-selection; @@ -856,6 +838,17 @@ a, img { } } +.open-files-container.active{ + li { + &.selected a { + color: @open-working-file-name-highlight; + } + + &.selected .extension { + color: @open-working-file-ext-highlight; + } + } +} .scroller-shadow { background-size: 100%; background-repeat: no-repeat; From eba535c2ddb16a88a4ed5cadcf17ee9a77227bd2 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Wed, 17 Sep 2014 01:37:43 -0700 Subject: [PATCH 5/8] restore the order --- src/styles/brackets.less | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 05463336868..e745340cce0 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -826,6 +826,18 @@ a, img { display:none; } +.open-files-container.active{ + li { + &.selected a { + color: @open-working-file-name-highlight; + } + + &.selected .extension { + color: @open-working-file-ext-highlight; + } + } +} + #project-files-container { .box-flex(1); @@ -838,17 +850,6 @@ a, img { } } -.open-files-container.active{ - li { - &.selected a { - color: @open-working-file-name-highlight; - } - - &.selected .extension { - color: @open-working-file-ext-highlight; - } - } -} .scroller-shadow { background-size: 100%; background-repeat: no-repeat; From 4df265ef59d7f836722be09b472e31e48afeadc4 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Wed, 17 Sep 2014 14:30:21 -0700 Subject: [PATCH 6/8] rtc: document _suppresRedraw flag and qualify affected working more rigorously wrt _suppressRedraw --- src/project/WorkingSetView.js | 41 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index ae231573b51..67b32c537ee 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -691,22 +691,37 @@ define(function (require, exports, module) { * @param {!string} paneId - the id of the pane the item that was to */ WorkingSetView.prototype._handleFileRemoved = function (e, file, suppressRedraw, paneId) { - if (paneId === this.paneId && !suppressRedraw) { - var $listItem = this._findListItemFromFile(file); - if ($listItem) { - // Make the next file in the list show the close icon, - // without having to move the mouse, if there is a next file. - var $nextListItem = $listItem.next(); - if ($nextListItem && $nextListItem.length > 0) { - var canClose = ($listItem.find(".can-close").length === 1); - var isDirty = _isOpenAndDirty($nextListItem.data(_FILE_KEY)); - this._updateFileStatusIcon($nextListItem, isDirty, canClose); + /* + * The suppressRedraw flag is used in cases when we are replacing the working + * set entry with another one. There are only 2 use cases for this: + * + * 1) When an untitled document is being saved. + * 2) When a file is saved with a new name. + */ + if (paneId === this.paneId) { + if (!suppressRedraw) { + var $listItem = this._findListItemFromFile(file); + if ($listItem) { + // Make the next file in the list show the close icon, + // without having to move the mouse, if there is a next file. + var $nextListItem = $listItem.next(); + if ($nextListItem && $nextListItem.length > 0) { + var canClose = ($listItem.find(".can-close").length === 1); + var isDirty = _isOpenAndDirty($nextListItem.data(_FILE_KEY)); + this._updateFileStatusIcon($nextListItem, isDirty, canClose); + } + $listItem.remove(); } - $listItem.remove(); + + this._redraw(); } - - this._redraw(); } else { + /* + * When this event is handled by a pane that is not being updated then + * the suppressRedraw flag does not need to be respected. + * _checkForDuplicatesInWorkingTree() does not remove any entries so it's + * safe to call at any time. + */ this._checkForDuplicatesInWorkingTree(); } }; From eefe6b32090ef3e55d91aa3df193f2ae169c340b Mon Sep 17 00:00:00 2001 From: JeffryBooher Date: Wed, 17 Sep 2014 22:58:06 -0700 Subject: [PATCH 7/8] restore the blues --- src/styles/brackets.less | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/styles/brackets.less b/src/styles/brackets.less index e745340cce0..64f65f00d23 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -767,6 +767,14 @@ a, img { padding: 0 0 0 8px; min-height: 18px; vertical-align: baseline; + + &.selected a { + color: @open-working-file-name-highlight; + } + + &.selected .extension { + color: @open-working-file-ext-highlight; + } } a { @@ -826,18 +834,6 @@ a, img { display:none; } -.open-files-container.active{ - li { - &.selected a { - color: @open-working-file-name-highlight; - } - - &.selected .extension { - color: @open-working-file-ext-highlight; - } - } -} - #project-files-container { .box-flex(1); From 2ecef074e2787f3cb5de0f94c7e52509f6ba74c0 Mon Sep 17 00:00:00 2001 From: JeffryBooher Date: Wed, 17 Sep 2014 23:21:39 -0700 Subject: [PATCH 8/8] fix tree selection issue --- src/project/FileViewController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index 00c6b6491e2..243cfd79f88 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -142,7 +142,8 @@ define(function (require, exports, module) { * @return {$.Promise} */ function openAndSelectDocument(fullPath, fileSelectionFocus, paneId) { - var result; + var result, + curDocChangedDueToMe = _curDocChangedDueToMe; if (fileSelectionFocus !== PROJECT_MANAGER && fileSelectionFocus !== WORKING_SET_VIEW) { console.error("Bad parameter passed to FileViewController.openAndSelectDocument"); @@ -172,7 +173,7 @@ define(function (require, exports, module) { // clear after notification is done result.always(function () { - _curDocChangedDueToMe = false; + _curDocChangedDueToMe = curDocChangedDueToMe; }); return result;