Convert FileFinder to a proper extension and remove references from RootView code

This commit is contained in:
Nathan Sobo
2012-05-07 19:30:07 -06:00
parent 81b7105a52
commit 31163f1d8c
8 changed files with 132 additions and 146 deletions

View File

@@ -1,6 +1,6 @@
window.keymap.bindKeys '*'
'meta-t': 'toggle-file-finder'
'meta-t': 'file-finder:toggle'
window.keymap.bindKeys ".file-finder .editor",
'enter': 'file-finder:select-file',
'escape': 'file-finder:close'
'escape': 'file-finder:cancel'

View File

@@ -32,8 +32,8 @@ class Project
getFilePaths: ->
projectPath = @path
fs.async.listTree(@path).pipe (paths) ->
path.replace(projectPath, "") for path in paths when fs.isFile(path)
fs.async.listTree(@path).pipe (paths) =>
@relativize(path) for path in paths when fs.isFile(path)
open: (filePath) ->
if filePath?

View File

@@ -6,7 +6,6 @@ _ = require 'underscore'
{View} = require 'space-pen'
Buffer = require 'buffer'
Editor = require 'editor'
FileFinder = require 'file-finder'
Project = require 'project'
VimMode = require 'vim-mode'
CommandPanel = require 'command-panel'
@@ -29,7 +28,6 @@ class RootView extends View
extensionStates: null
initialize: ({ pathToOpen, projectPath, panesViewState, @extensionStates }) ->
@on 'toggle-file-finder', => @toggleFileFinder()
@on 'show-console', => window.showConsole()
@on 'focus', (e) =>
if @activeEditor()
@@ -74,7 +72,7 @@ class RootView extends View
serializeExtensions: ->
extensionStates = {}
for name, extension of @extensions
extensionStates[name] = extension.serialize()
extensionStates[name] = extension.serialize?()
extensionStates
@@ -91,7 +89,7 @@ class RootView extends View
deactivate: ->
atom.rootViewStates[$windowNumber] = @serialize()
extension.deactivate() for name, extension of @extensions
extension.deactivate?() for name, extension of @extensions
@remove()
open: (path, changeFocus=true) ->
@@ -139,21 +137,6 @@ class RootView extends View
rootPane?.css(width: '100%', height: '100%', top: 0, left: 0)
rootPane?.adjustDimensions()
toggleFileFinder: ->
return unless @project.getPath()?
if @fileFinder and @fileFinder.parent()[0]
@fileFinder.remove()
@fileFinder = null
else
@project.getFilePaths().done (paths) =>
relativePaths = (@project.relativize(path) for path in paths)
@fileFinder = new FileFinder
paths: relativePaths
selected: (relativePath) => @open(relativePath)
@append @fileFinder
@fileFinder.editor.focus()
remove: ->
editor.remove() for editor in @editors()
super