mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Display relative paths in the file finder
This commit is contained in:
@@ -4,11 +4,13 @@ RootView = require 'root-view'
|
||||
|
||||
describe "RootView", ->
|
||||
rootView = null
|
||||
project = null
|
||||
url = null
|
||||
|
||||
beforeEach ->
|
||||
url = require.resolve 'fixtures/dir/a'
|
||||
rootView = RootView.build {url}
|
||||
project = rootView.project
|
||||
|
||||
describe "initialize", ->
|
||||
describe "when called with a url that references a file", ->
|
||||
@@ -49,11 +51,17 @@ describe "RootView", ->
|
||||
rootView.toggleFileFinder()
|
||||
expect(rootView.find('.file-finder')).not.toExist()
|
||||
|
||||
it "shows all urls for the current project", ->
|
||||
fit "shows all relative file paths for the current project", ->
|
||||
waitsForPromise ->
|
||||
rootView.toggleFileFinder()
|
||||
runs ->
|
||||
expect(rootView.fileFinder.urlList.children('li').length).toBe 3
|
||||
|
||||
waitsForPromise ->
|
||||
project.getFilePaths().done (paths) ->
|
||||
expect(rootView.fileFinder.urlList.children('li').length).toBe paths.length
|
||||
|
||||
for path in paths
|
||||
relativePath = path.replace(project.url, '')
|
||||
expect(rootView.fileFinder.urlList.find("li:contains(#{relativePath}):not(:contains(#{project.url}))")).toExist()
|
||||
|
||||
describe "when there is no project", ->
|
||||
beforeEach ->
|
||||
@@ -65,3 +73,14 @@ describe "RootView", ->
|
||||
rootView.toggleFileFinder()
|
||||
expect(rootView.find('.file-finder')).not.toExist()
|
||||
|
||||
fdescribe "when a path is selected in the file finder", ->
|
||||
it "opens the file associated with that path in the editor", ->
|
||||
waitsForPromise -> rootView.toggleFileFinder()
|
||||
runs ->
|
||||
firstLi = rootView.fileFinder.find('li:first')
|
||||
rootView.fileFinder.select()
|
||||
expect(rootView.editor.buffer.url).toBe(project.url + firstLi.text())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ class RootView extends Template
|
||||
@fileFinder.remove()
|
||||
@fileFinder = null
|
||||
else
|
||||
@project.getFilePaths().done (urls) =>
|
||||
@fileFinder = FileFinder.build({urls, selected: (url) => @editor.open(url)})
|
||||
@project.getFilePaths().done (paths) =>
|
||||
relativePaths = (path.replace(@project.url, "") for path in paths)
|
||||
@fileFinder = FileFinder.build({urls: relativePaths, selected: (relativePath) => @editor.open(@project.url + relativePath)})
|
||||
@addPane(@fileFinder)
|
||||
@fileFinder.input.focus()
|
||||
|
||||
Reference in New Issue
Block a user