Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Fix for same doc drag across panes in working set and same doc flip u…
Browse files Browse the repository at this point in the history
…sing pane header.
  • Loading branch information
swmitra committed Jan 12, 2016
1 parent 953d97e commit d72753b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 37 deletions.
37 changes: 21 additions & 16 deletions src/project/WorkingSetView.js
Expand Up @@ -788,22 +788,27 @@ define(function (require, exports, module) {
MainViewManager._moveWorkingSetItem(sourceView.paneId, startingIndex, $el.index());
postDropCleanup();
} else {
// item was dragged to another working set
MainViewManager._moveView(sourceView.paneId, currentView.paneId, sourceFile, $el.index())
.always(function () {
// if the current document was dragged to another working set
// then reopen it to make it the currently selected file
if (draggingCurrentFile) {
CommandManager
.execute(Commands.FILE_OPEN, {fullPath: sourceFile.fullPath,
paneId: currentView.paneId})
.always(function () {
postDropCleanup();
});
} else {
postDropCleanup();
}
});
// If the same doc view is present in the destination pane prevent drop
if (!MainViewManager._getPane(currentView.paneId).getViewForPath(sourceFile.fullPath)) {
// item was dragged to another working set
MainViewManager._moveView(sourceView.paneId, currentView.paneId, sourceFile, $el.index())
.always(function () {
// if the current document was dragged to another working set
// then reopen it to make it the currently selected file
if (draggingCurrentFile) {
CommandManager
.execute(Commands.FILE_OPEN, {fullPath: sourceFile.fullPath,
paneId: currentView.paneId})
.always(function () {
postDropCleanup();
});
} else {
postDropCleanup();
}
});
} else {
postDropCleanup();
}
}
}

Expand Down
44 changes: 23 additions & 21 deletions src/view/Pane.js
Expand Up @@ -245,6 +245,11 @@ define(function (require, exports, module) {
var currentFile = self.getCurrentlyViewedFile();
var otherPaneId = self.id === FIRST_PANE ? SECOND_PANE : FIRST_PANE;
var otherPane = MainViewManager._getPane(otherPaneId);

// If the same doc view is present in the destination pane prevent flip
if (otherPane.getViewForPath(currentFile.fullPath)) {
return;
}

// Currently active pane is not necessarily self.id as just clicking the button does not
// give focus to the pane. This way it is possible to flip multiple panes to the active one
Expand All @@ -257,28 +262,25 @@ define(function (require, exports, module) {
CommandManager.execute(Commands.FILE_CLOSE, {File: currentFile, paneId: self.id});
}

// If the same doc view is present in the destination pane prevent flip
if (!otherPane.getViewForPath(currentFile.fullPath)) {
MainViewManager._moveView(self.id, otherPaneId, currentFile).always(function () {
CommandManager.execute(Commands.FILE_OPEN, {fullPath: currentFile.fullPath,
paneId: otherPaneId}).always(function () {

var activePaneBeforeFlip = MainViewManager._getPane(activePaneIdBeforeFlip);

// Trigger view list changes for both panes
self.trigger("viewListChange");
otherPane.trigger("viewListChange");

// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the original pane.
activePaneBeforeFlip.focus();
self._lastFocusedElement = activePaneBeforeFlip.$el[0];
MainViewManager.setActivePaneId(activePaneIdBeforeFlip);
}, 1);
});
MainViewManager._moveView(self.id, otherPaneId, currentFile).always(function () {
CommandManager.execute(Commands.FILE_OPEN, {fullPath: currentFile.fullPath,
paneId: otherPaneId}).always(function () {

var activePaneBeforeFlip = MainViewManager._getPane(activePaneIdBeforeFlip);

// Trigger view list changes for both panes
self.trigger("viewListChange");
otherPane.trigger("viewListChange");

// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the original pane.
activePaneBeforeFlip.focus();
self._lastFocusedElement = activePaneBeforeFlip.$el[0];
MainViewManager.setActivePaneId(activePaneIdBeforeFlip);
}, 1);
});
}
});
});

// Closes the current view on the pane when clicked. If pane has no files, merge
Expand Down

0 comments on commit d72753b

Please sign in to comment.