-
Notifications
You must be signed in to change notification settings - Fork 7.6k
command to swap visible files between panes per issue #13061 #13150
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* MainViewManager manages the arrangement of all open panes as well as provides the controller | ||
* logic behind all views in the MainView (e.g. ensuring that a file doesn't appear in 2 lists) | ||
* | ||
* Each pane contains one or more views wich are created by a view factory and inserted into a pane list. | ||
* Each pane contains one or more views which are created by a view factory and inserted into a pane list. | ||
* There may be several panes managed by the MainViewManager with each pane containing a list of views. | ||
* The panes are always visible and the layout is determined by the MainViewManager and the user. | ||
* | ||
|
@@ -140,6 +140,7 @@ define(function (require, exports, module) { | |
*/ | ||
var SECOND_PANE = "second-pane"; | ||
|
||
|
||
/* | ||
* NOTE: The following commands and constants will change | ||
* when implementing the UX UI Treatment @larz0 | ||
|
@@ -845,6 +846,62 @@ define(function (require, exports, module) { | |
return result.promise(); | ||
} | ||
|
||
/** | ||
* swaps current views to opposite panes | ||
*/ | ||
function swapPaneContent() { | ||
|
||
var activeFileInactiveView, | ||
inactiveFileActiveView, | ||
activePaneId = getActivePaneId(), | ||
inactivePaneId = activePaneId === FIRST_PANE ? SECOND_PANE : FIRST_PANE, | ||
activePane = _getPane(activePaneId), | ||
inactivePane = _getPane(inactivePaneId), | ||
activeFile = activePane.getCurrentlyViewedFile(), | ||
inactiveFile = inactivePane.getCurrentlyViewedFile(); | ||
|
||
// Check if one of the panes is empty move and open currently viewed file in opposite pane. | ||
// if both are empty do nothing. | ||
if (!activeFile || !inactiveFile) { | ||
if (!activeFile && inactiveFile) { | ||
_moveView(inactivePaneId, activePaneId, inactiveFile, 0); | ||
} else if (!inactiveFile && activeFile) { | ||
_moveView(activePaneId, inactivePaneId, activeFile, 0); | ||
} | ||
|
||
} else { | ||
|
||
// check if currently viewed file is present in opposing pane. If it is open the file. | ||
// if it is not add it to the opposite pane and open. | ||
activeFileInactiveView = inactivePane.getViewForPath(activeFile.fullPath); | ||
inactiveFileActiveView = activePane.getViewForPath(inactiveFile.fullPath); | ||
|
||
if (inactiveFileActiveView) { | ||
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 could probably be a method like 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. @petetnt I looked into moving most of what is now in MainViewManager onto the pane prototype (see below), and I can push up the commit including it, however, with this setup I can't seem to get the active pane to consistently stay in place. It flips from one pane to the other every third swap. I've tried promises and a few other ideas, but Maybe I'm missing something obvious. Any insights are welcome. Pane.prototype.swapPaneContent = function(oppositeFile) {
var self = this,
oppositePane = self.id === FIRST_PANE ? SECOND_PANE : FIRST_PANE;
if(!oppositeFile){
var file = self.getCurrentlyViewedFile();
MainViewManager._moveView( self.id, oppositePane.id, file , 0);
} else {
if (self.getViewForPath(oppositeFile.fullPath)) {
CommandManager.execute(Commands.FILE_OPEN, {
fullPath: oppositeFile.fullPath,
paneId: self.id
});
} else {
CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, {
fullPath: oppositeFile.fullPath,
paneId: self.id
});
};
};
}; function swapPaneContent() {
var activePaneId = getActivePaneId(),
inactivePaneId = activePaneId === FIRST_PANE ? SECOND_PANE : FIRST_PANE,
activePane = _getPane(activePaneId),
inactivePane = _getPane(inactivePaneId),
activeFile = activePane.getCurrentlyViewedFile(),
inactiveFile = inactivePane.getCurrentlyViewedFile();
inactivePane.swapPaneContent(activeFile); // addition
activePane.swapPaneContent(inactiveFile); // addition
}; 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 don't like this rewrite ... 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. Yeah, my idea was something in line with the rewrite but just calling the method with The original code is fine by me too if you think so too, you call @SteveMieskoski 👍 |
||
CommandManager.execute(Commands.FILE_OPEN, { | ||
fullPath: inactiveFile.fullPath, | ||
paneId: activePaneId | ||
}); | ||
} else { | ||
CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, { | ||
fullPath: inactiveFile.fullPath, | ||
paneId: activePaneId | ||
}); | ||
} | ||
|
||
if (activeFileInactiveView) { | ||
CommandManager.execute(Commands.FILE_OPEN, { | ||
fullPath: activeFile.fullPath, | ||
paneId: inactivePaneId | ||
}); | ||
} else { | ||
CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, { | ||
fullPath: activeFile.fullPath, | ||
paneId: inactivePaneId | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* Switch between panes | ||
*/ | ||
|
@@ -1752,6 +1809,7 @@ define(function (require, exports, module) { | |
exports.getAllOpenFiles = getAllOpenFiles; | ||
exports.focusActivePane = focusActivePane; | ||
exports.switchPaneFocus = switchPaneFocus; | ||
exports.swapPaneContent = swapPaneContent; | ||
|
||
// Layout | ||
exports.setLayoutScheme = setLayoutScheme; | ||
|
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.
revert this change, it happens automatically after
npm install
but shouldn't be committedThere 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.
Corrected the change, and that's good to know, thanks.