Last active
May 11, 2018 21:43
-
-
Save csvoss/0146ca936fa1a0b8086b2f978a1f3a5c to your computer and use it in GitHub Desktop.
Atom: Merge and close panes
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
# Derived from the solutions discussed at github.com/atom/atom/issues/380. In | |
# particular, I converted one of the Javascript solutions to Coffeescript and | |
# added my own modifications to ensure that panes get closed on deletion. | |
atom.commands.add "atom-workspace", "custom:pane-merge", -> | |
panes = atom.workspace.getCenter().getPanes() | |
firstPane = panes.shift() | |
for pane in panes | |
for item in pane.getItems() | |
if (firstPane.getItems().find(findItemInPane(item))) | |
pane.destroyItem(item) | |
else | |
pane.moveItemToPane(item, firstPane) | |
pane.destroy() | |
findItemInPane = (nonFirstPaneItem) -> | |
(firstPaneItem) -> | |
if Object.getPrototypeOf(firstPaneItem).constructor.name == 'TextEditor' and Object.getPrototypeOf(nonFirstPaneItem).constructor.name == 'TextEditor' | |
firstPaneItem.getPath() == nonFirstPaneItem.getPath() | |
else | |
firstPaneItem.uri == nonFirstPaneItem.uri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment