mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add config.fuzzy-finder.ignoredNames
This commit is contained in:
@@ -3,7 +3,7 @@ FuzzyFinder = require 'fuzzy-finder'
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
|
||||
describe 'FuzzyFinder', ->
|
||||
fdescribe 'FuzzyFinder', ->
|
||||
[rootView, finder] = []
|
||||
|
||||
beforeEach ->
|
||||
@@ -228,3 +228,17 @@ describe 'FuzzyFinder', ->
|
||||
|
||||
runs ->
|
||||
expect(rootView.project.getFilePaths).toHaveBeenCalled()
|
||||
|
||||
describe "path ignoring", ->
|
||||
it "ignores paths that match entries in config.fuzzy-finder.ignoredNames", ->
|
||||
config.update("fuzzy-finder.ignoredNames", ["tree-view"])
|
||||
rootView.trigger 'fuzzy-finder:toggle-file-finder'
|
||||
finder.maxItems = Infinity
|
||||
finder.miniEditor.setText("file1")
|
||||
|
||||
waitsFor ->
|
||||
finder.list.children('li').length > 0
|
||||
|
||||
runs ->
|
||||
expect(finder.list).toContain("li:contains(dir/file1)")
|
||||
expect(finder.list).not.toContain("li:contains(dir1/file1)")
|
||||
|
||||
@@ -23,6 +23,8 @@ class FuzzyFinder extends SelectList
|
||||
initialize: (@rootView) ->
|
||||
super
|
||||
$(window).on 'focus', => @array = null
|
||||
@observeConfig 'fuzzy-finder.ignoredNames', (ignoredNames) =>
|
||||
@projectPaths = null
|
||||
|
||||
itemForElement: (path) ->
|
||||
$$ -> @li path
|
||||
@@ -59,8 +61,16 @@ class FuzzyFinder extends SelectList
|
||||
else
|
||||
@setLoading("Indexing...")
|
||||
@rootView.project.getFilePaths().done (paths) =>
|
||||
ignoredNames = config.get("fuzzy-finder.ignoredNames")
|
||||
console.log config
|
||||
@projectPaths = paths
|
||||
@setArray(paths)
|
||||
if ignoredNames
|
||||
@projectPaths = @projectPaths.filter (path) ->
|
||||
for segment in path.split("/")
|
||||
return false if _.contains(ignoredNames, segment)
|
||||
return true
|
||||
|
||||
@setArray(@projectPaths)
|
||||
|
||||
populateOpenBufferPaths: ->
|
||||
@paths = @rootView.getOpenBufferPaths().map (path) =>
|
||||
|
||||
Reference in New Issue
Block a user