mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
super basic "ack in project" (cmd-shift-f)
the UI could use some improvements
This commit is contained in:
27
extensions/findinproject/find-in-project.coffee
Normal file
27
extensions/findinproject/find-in-project.coffee
Normal file
@@ -0,0 +1,27 @@
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
|
||||
ChildProcess = require 'child-process'
|
||||
Extension = require 'extension'
|
||||
ModalSelector = require 'modal-selector'
|
||||
|
||||
module.exports =
|
||||
class FindInProject extends Extension
|
||||
constructor: ->
|
||||
atom.on 'project:open', @startup
|
||||
|
||||
startup: (@project) =>
|
||||
|
||||
query: ->
|
||||
return if not @project
|
||||
@findInProject (prompt "Find in project:"), (results) =>
|
||||
@pane = new ModalSelector -> results
|
||||
@pane.show()
|
||||
|
||||
findInProject: (term, callback) ->
|
||||
root = @project.url
|
||||
ChildProcess.exec "ack --ignore-dir=Cocoa/build --ignore-dir=vendor #{term} #{@project.url}", (error, stdout, stderr) ->
|
||||
callback _.map (stdout.split "\n"), (line) ->
|
||||
name: line.replace root, ''
|
||||
url: _.first line.split ":"
|
||||
|
||||
1
extensions/findinproject/index.coffee
Normal file
1
extensions/findinproject/index.coffee
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require 'findinproject/find-in-project'
|
||||
2
extensions/findinproject/key-bindings.coffee
Normal file
2
extensions/findinproject/key-bindings.coffee
Normal file
@@ -0,0 +1,2 @@
|
||||
findinproject:
|
||||
'cmd-shift-f': (findinproject) => findinproject.query()
|
||||
Reference in New Issue
Block a user