Skip to content

Fix jQuery-isms that are removed in Atom 1.16; Update observePanes call to deal with Docks being introduced in Atom 1.17; Fix tree-view toggle toggling tree-view-open-files backwards; General cleanup #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions lib/tree-view-open-files-view.coffee
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{requirePackages} = require 'atom-utils'
{CompositeDisposable} = require 'event-kit'
_ = require 'lodash'

TreeViewOpenFilesPaneView = require './tree-view-open-files-pane-view'

module.exports =
class TreeViewOpenFilesView
constructor: (serializeState) ->
constructor: (treeView) ->
@treeView = treeView

# Create root element
@element = document.createElement('div')
@element.classList.add('tree-view-open-files')
@groups = []
@paneSub = new CompositeDisposable
@paneSub.add atom.workspace.observePanes (pane) =>
@addTabGroup pane
destroySub = pane.onDidDestroy =>
destroySub.dispose()
@removeTabGroup pane
@paneSub.add destroySub
if(atom.workspace.isTextEditor(pane.getActiveItem()))
@addTabGroup pane
destroySub = pane.onDidDestroy =>
destroySub.dispose()
@removeTabGroup pane
@paneSub.add destroySub

@configSub = atom.config.observe 'tree-view-open-files.maxHeight', (maxHeight) =>
@element.style.maxHeight = if maxHeight > 0 then "#{maxHeight}px" else 'none'
Expand All @@ -33,9 +35,6 @@ class TreeViewOpenFilesView
@groups[group].destroy()
@groups.splice group, 1

# Returns an object that can be retrieved when package is activated
serialize: ->

# Tear down any state and detach
destroy: ->
@element.remove()
Expand All @@ -53,6 +52,4 @@ class TreeViewOpenFilesView
@element.remove()

show: ->
requirePackages('tree-view').then ([treeView]) =>
treeView.treeView.find('.tree-view-scroller').css 'background', treeView.treeView.find('.tree-view').css 'background'
treeView.treeView.prepend @element
@treeView.treeView.element.insertBefore(@element, @treeView.treeView.element.firstChild)
8 changes: 2 additions & 6 deletions lib/tree-view-open-files.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ module.exports =

activate: (state) ->
requirePackages('tree-view').then ([treeView]) =>
@treeViewOpenFilesView = new TreeViewOpenFilesView
@treeViewOpenFilesView = new TreeViewOpenFilesView(treeView)

if treeView.treeView
@treeViewOpenFilesView.show()

atom.commands.add 'atom-workspace', 'tree-view:toggle', =>
if treeView.treeView?.is(':visible')
@treeViewOpenFilesView.show()
else
@treeViewOpenFilesView.hide()
@treeViewOpenFilesView.toggle()

atom.commands.add 'atom-workspace', 'tree-view:show', =>
@treeViewOpenFilesView.show()
Expand All @@ -31,4 +28,3 @@ module.exports =
@treeViewOpenFilesView.destroy()

serialize: ->
#TreeViewOpenFilesViewState: @TreeViewOpenFilesView.serialize()