diff --git a/plugins/project/project.coffee b/plugins/project/project.coffee index 8838c66d9..dabf044e8 100644 --- a/plugins/project/project.coffee +++ b/plugins/project/project.coffee @@ -20,51 +20,49 @@ class Project extends Pane initialize: -> @reload(File.workingDirectory()) @editor = activeWindow.document - + @editor.ace.on 'open', ({filename}) => if File.isDirectory filename @reload filename else - openedPaths = @get 'openPaths', [] - if not openedPaths.indexOf filename + openedPaths = @get 'openedPaths', [] + if not _.include openedPaths, filename openedPaths.push filename - @set 'openPaths', openedPaths + @set 'openedPaths', openedPaths @editor.ace.on 'close', ({filename}) => if File.isFile filename - openedPaths = _.without @get('openPaths', []), filename - @set 'openPaths', openedPaths + openedPaths = _.without @get('openedPaths', []), filename + @set 'openedPaths', openedPaths @editor.ace.on 'loaded', => # Reopen files (remove ones that no longer exist) - openedPaths = @get 'openPaths', [] + openedPaths = @get 'openedPaths', [] for path in openedPaths - if File.exists path + if File.isFile path @editor.open path else openedPaths = _.without(openedPaths, path) @set "openedPaths", openedPaths - + $('#project li').live 'click', (event) => $('#project .active').removeClass 'active' el = $(event.currentTarget) path = decodeURIComponent el.attr 'path' if File.isDirectory path - visibleDirs = @get('visibleDirs') or {} + openedPaths = @get('openedPaths', []) if el.hasClass 'open' - delete visibleDirs[path] - + openedPaths = _.without(openedPaths, path) el.removeClass 'open' el.children("ul").remove() else - visibleDirs[path] = true - + openedPaths.push path unless _.include openedPaths, path el.addClass 'open' list = @createList path el.append list - @set('visibleDirs', visibleDirs) + @set 'openedPaths', openedPaths else el.addClass 'active' activeWindow.open path @@ -80,18 +78,17 @@ class Project extends Pane createList: (dir) -> paths = File.list dir - - # BUG: need to clear visibleDirs that don't exist anymore - visibleDirs = @get('visibleDirs', {}) + + openedPaths = @get('openedPaths', []) list = $('