Empty fuzzy-finder list on cancel

This commit is contained in:
Corey Johnson & Kevin Sawicki
2012-12-12 15:08:20 -08:00
parent 81eed5e410
commit 0c68295ec6
3 changed files with 9 additions and 17 deletions

View File

@@ -132,11 +132,12 @@ describe "SelectList", ->
expect(selectList.confirmed).toHaveBeenCalledWith(array[1])
describe "the core:cancel event", ->
it "triggers the cancelled hook and detaches the select list", ->
it "triggers the cancelled hook and detaches and empties the select list", ->
spyOn(selectList, 'detach')
miniEditor.trigger 'core:cancel'
expect(selectList.cancelled).toHaveBeenCalled()
expect(selectList.detach).toHaveBeenCalled()
expect(selectList.list).toBeEmpty()
describe "when the mini editor loses focus", ->
it "triggers the cancelled hook and detaches the select list", ->
@@ -144,13 +145,3 @@ describe "SelectList", ->
miniEditor.trigger 'focusout'
expect(selectList.cancelled).toHaveBeenCalled()
expect(selectList.detach).toHaveBeenCalled()
describe "when an error occurs on previously populated list", ->
it "clears the list", ->
selectList.setError("yolo")
expect(selectList.list).toBeEmpty()
describe "when loading is triggered on previously populated list", ->
it "clears the list", ->
selectList.setLoading("loading yolo")
expect(selectList.list).toBeEmpty()

View File

@@ -48,7 +48,6 @@ class SelectList extends View
@error.text("").hide()
@removeClass("error")
else
@list.empty()
@error.text(message).show()
@addClass("error")
@@ -56,7 +55,6 @@ class SelectList extends View
if not message or message.length == ""
@loading.text("").hide()
else
@list.empty()
@setError()
@loading.text(message).show()
@@ -115,6 +113,7 @@ class SelectList extends View
@confirmed(element) if element?
cancel: ->
@list.empty()
@cancelling = true
@cancelled()
@detach()

View File

@@ -51,10 +51,12 @@ class FuzzyFinder extends SelectList
@attach() if @paths?.length
populateProjectPaths: ->
return if @array?.length > 0
@setLoading("Indexing...")
@rootView.project.getFilePaths().done (paths) =>
@setArray(paths)
if @array?.length > 0
@setArray(@array)
else
@setLoading("Indexing...")
@rootView.project.getFilePaths().done (paths) =>
@setArray(paths)
populateOpenBufferPaths: ->
@paths = @rootView.getOpenBufferPaths().map (path) =>