Display error when symbol's file does not exist

This commit is contained in:
Kevin Sawicki
2013-02-28 15:06:48 -08:00
parent 1b71796698
commit 35ca8a42a1
2 changed files with 32 additions and 2 deletions

View File

@@ -77,8 +77,12 @@ class SymbolsView extends SelectList
setTimeout (=> @cancel()), 2000
confirmed : (tag) ->
@cancel()
@openTag(tag)
if tag.file and not fs.isFile(project.resolve(tag.file))
@setError('Selected file does not exist')
setTimeout((=> @setError()), 2000)
else
@cancel()
@openTag(tag)
openTag: (tag) ->
position = tag.position

View File

@@ -201,3 +201,29 @@ describe "SymbolsView", ->
expect(symbolsView.list.children('li:last').find('.function-details')).toHaveText 'tagged.js'
expect(symbolsView).not.toHaveClass "error"
expect(symbolsView.error).not.toBeVisible()
describe "when selecting a tag", ->
describe "when the file doesn't exist", ->
renamedPath = null
beforeEach ->
renamedPath = project.resolve("tagged-renamed.js")
fs.remove(renamedPath) if fs.exists(renamedPath)
fs.move(project.resolve("tagged.js"), renamedPath)
afterEach ->
fs.move(renamedPath, project.resolve("tagged.js"))
it "doesn't open the editor", ->
rootView.trigger "symbols-view:toggle-project-symbols"
symbolsView = rootView.find('.symbols-view').view()
waitsFor ->
setArraySpy.callCount > 0
runs ->
spyOn(rootView, 'open').andCallThrough()
symbolsView.list.children('li:first').mousedown().mouseup()
expect(rootView.open).not.toHaveBeenCalled()
expect(symbolsView.error.text().length).toBeGreaterThan 0
expect(symbolsView).toHaveClass "error"