diff --git a/extensions/tabs/tabs-pane.coffee b/extensions/tabs/tabs-pane.coffee
new file mode 100644
index 000000000..2e51b0487
--- /dev/null
+++ b/extensions/tabs/tabs-pane.coffee
@@ -0,0 +1,57 @@
+$ = require 'jquery'
+_ = require 'underscore'
+
+Pane = require 'pane'
+
+module.exports =
+class TabsPane extends Pane
+ position: 'top'
+
+ html: $ require 'tabs/tabs.html'
+
+ constructor: ->
+ # Style html
+ @html.parents('.pane').css height: 'inherit'
+ css = $('').html require 'tabs/tabs.css'
+ $('head').append css
+
+ # click tab
+ tabPane = this
+ $('#tabs ul li').live 'mousedown', ->
+ tabPane.switchToTab this
+ false
+
+ nextTab: ->
+ @switchToTab $('#tabs ul .active').next()
+
+ prevTab: ->
+ @switchToTab $('#tabs ul .active').prev()
+
+ switchToTab: (tab) ->
+ tab = $("#tabs ul li").get(tab - 1) if _.isNumber tab
+ return if tab.length is 0
+
+ $("#tabs ul .active").removeClass("active")
+ $(tab).addClass 'active'
+ window.editor.focusBuffer $(tab).data 'path'
+
+ addTab: (path) ->
+ existing = $("#tabs [data-path='#{path}']")
+ if existing.length
+ return @switchToTab existing
+
+ name = if path then _.last path.split '/' else "untitled"
+ $("#tabs ul .active").removeClass()
+ $("#tabs ul").append """
+
#{name}
+ """
+ $("#tabs ul li:last").addClass 'active'
+
+ removeTab: (path) ->
+ tab = $("#tabs li[data-path='#{path}']")
+ if tab.hasClass("active")
+ nextTab = tab.next()
+ nextTab = tab.prev() if nextTab.length == 0
+ @switchToTab nextTab if nextTab.length != 0
+
+ tab.remove()
diff --git a/extensions/tree/tree-pane.coffee b/extensions/tree/tree-pane.coffee
index 0212fe7ae..08705b389 100644
--- a/extensions/tree/tree-pane.coffee
+++ b/extensions/tree/tree-pane.coffee
@@ -26,17 +26,15 @@ class TreePane extends Pane
if fs.isDirectory path
window.x = @tree
- openedDirs = @tree.getOpenedDirs()
if el.hasClass 'open'
- openedDirs = _.without openedDirs, path
+ @tree.hideDir path
el.removeClass 'open'
el.children("ul").remove()
else
- openedDirs.push path unless path in openedDirs
+ @tree.showDir path
el.addClass 'open'
list = @createList path
el.append list
- @tree.setOpenedDirs openedDirs
else
el.addClass 'active'
window.open path
@@ -58,14 +56,14 @@ class TreePane extends Pane
paths = fs.list root
list = $('')
+ console.log @tree.shownDirs()
for path in paths
filename = path.replace(root, "").substring 1
type = if fs.isDirectory path then 'dir' else 'file'
encodedPath = encodeURIComponent path
listItem = $("- #{filename}
")
- openedDirs = @tree.getOpenedDirs()
- if path in openedDirs and fs.isDirectory path
+ if path in @tree.shownDirs() and fs.isDirectory path
listItem.append @createList path
listItem.addClass "open"
list.append listItem
diff --git a/extensions/tree/tree.coffee b/extensions/tree/tree.coffee
index 2c37852b6..742d6889d 100644
--- a/extensions/tree/tree.coffee
+++ b/extensions/tree/tree.coffee
@@ -15,21 +15,23 @@ class Tree extends Extension
KeyBinder.load require.resolve "tree/key-bindings.coffee"
# Remove dirs that no longer exist
- openedPaths = @getOpenedDirs()
- for dir in openedPaths when not fs.exists dir
- openedDirs = _.without openedDirs, path
- @setOpenedDirs openedDirs
+ @hideDir(dir) for dir in @shownDirs() when not fs.exists dir
@pane = new TreePane @
- storageNamespace: ->
- @.constructor.name + ":" + atomController.path
-
- getOpenedDirs: ->
- Storage.get @storageNamespace() + ':openedDirs', []
-
- setOpenedDirs: (value) ->
- Storage.set @storageNamespace() + ':openedDirs', value
-
startup: ->
@pane.show()
+
+ shownDirStorageKey: ->
+ @.constructor.name + ":" + atomController.path + ":shownDirs"
+
+ shownDirs: ->
+ Storage.get @shownDirStorageKey(), []
+
+ showDir: (dir) ->
+ dirs = @shownDirs().concat dir
+ Storage.set @shownDirStorageKey(), dirs
+
+ hideDir: (dir) ->
+ dirs = _.without @shownDirs(), dir
+ Storage.set @shownDirStorageKey(), dirs