From 4121b2076e99dfdad19d0ee9c4f4d30e4ead7f47 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 5 Jan 2012 11:01:17 -0800 Subject: [PATCH] Display relative paths in the file finder --- spec/atom/root-view-spec.coffee | 25 ++++++++++++++++++++++--- src/atom/root-view.coffee | 5 +++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/spec/atom/root-view-spec.coffee b/spec/atom/root-view-spec.coffee index 3ba05cfba..5cd656b69 100644 --- a/spec/atom/root-view-spec.coffee +++ b/spec/atom/root-view-spec.coffee @@ -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()) + + + + diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index 69c5ce40f..15d088aee 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -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()