Bind meta-T to display modified/untracked files

This commit is contained in:
Kevin Sawicki
2013-02-28 12:25:55 -08:00
parent 77bc42bd45
commit 4c773439d2
4 changed files with 47 additions and 0 deletions

View File

@@ -2,3 +2,4 @@
'meta-t': 'fuzzy-finder:toggle-file-finder'
'meta-b': 'fuzzy-finder:toggle-buffer-finder'
'ctrl-.': 'fuzzy-finder:find-under-cursor'
'meta-T': 'fuzzy-finder:toggle-git-status-finder'

View File

@@ -103,6 +103,15 @@ class FuzzyFinderView extends SelectList
@populateOpenBufferPaths()
@attach() if @paths?.length
toggleGitFinder: ->
if @hasParent()
@cancel()
else
return unless project.getPath()? and git?
@allowActiveEditorChange = false
@populateGitStatusPaths()
@attach()
findUnderCursor: ->
if @hasParent()
@cancel()
@@ -126,6 +135,13 @@ class FuzzyFinderView extends SelectList
@attach()
@miniEditor.setText(currentWord)
populateGitStatusPaths: ->
projectRelativePaths = []
for path, status of git.statuses
continue unless fs.isFile(path)
projectRelativePaths.push(project.relativize(path))
@setArray(projectRelativePaths)
populateProjectPaths: (options = {}) ->
if @projectPaths?.length > 0
listedItems =

View File

@@ -12,6 +12,8 @@ module.exports =
@createView().toggleBufferFinder()
rootView.command 'fuzzy-finder:find-under-cursor', =>
@createView().findUnderCursor()
rootView.command 'fuzzy-finder:toggle-git-status-finder', =>
@createView().toggleGitFinder()
if project.getPath()?
LoadPathsTask = require 'fuzzy-finder/lib/load-paths-task'

View File

@@ -215,6 +215,34 @@ describe 'FuzzyFinder', ->
expect(editor2.getPath()).toBe expectedPath
expect(editor2.isFocused).toBeTruthy()
describe "git-status-finder behavior", ->
[originalText, originalPath, newPath] = []
beforeEach ->
editor = rootView.getActiveEditor()
originalText = editor.getText()
originalPath = editor.getPath()
fs.write(originalPath, 'making a change for the better')
git.getPathStatus(originalPath)
newPath = project.resolve('newsample.js')
fs.write(newPath, '')
git.getPathStatus(newPath)
afterEach ->
fs.write(originalPath, originalText)
fs.remove(newPath) if fs.exists(newPath)
it "displays all new and modified paths", ->
expect(rootView.find('.fuzzy-finder')).not.toExist()
rootView.trigger 'fuzzy-finder:toggle-git-status-finder'
expect(rootView.find('.fuzzy-finder')).toExist()
expect(finderView.find('.file').length).toBe 2
expect(finderView.find('.status.modified').length).toBe 1
expect(finderView.find('.status.new').length).toBe 1
describe "common behavior between file and buffer finder", ->
describe "when the fuzzy finder is cancelled", ->
describe "when an editor is open", ->