Skip to content

Instantly share code, notes, and snippets.

@csvoss
Last active May 11, 2018 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csvoss/0146ca936fa1a0b8086b2f978a1f3a5c to your computer and use it in GitHub Desktop.
Save csvoss/0146ca936fa1a0b8086b2f978a1f3a5c to your computer and use it in GitHub Desktop.
Atom: Merge and close panes
# 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