From b27a465e2fb7c419ea8318925b1bb61498a99a54 Mon Sep 17 00:00:00 2001 From: John Barnette Date: Tue, 12 Mar 2013 18:37:02 -0700 Subject: [PATCH 1/7] Use absolute paths inside fuzzy-finder This allows paths from outside the current project root to sanely coexist in the buffer list. --- .../fuzzy-finder/lib/fuzzy-finder-view.coffee | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee index d12f6f29a..5212b3c2f 100644 --- a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee +++ b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee @@ -39,7 +39,7 @@ class FuzzyFinderView extends SelectList $$ -> @li => if git? - status = git.statuses[project.resolve(path)] + status = git.statuses[path] if git.isStatusNew(status) @div class: 'status new' else if git.isStatusModified(status) @@ -61,7 +61,7 @@ class FuzzyFinderView extends SelectList @span fs.base(path), class: "file label #{typeClass}" if folder = fs.directory(path) - @span " - #{folder}/", class: 'directory' + @span " - #{project.relativize(folder)}/", class: 'directory' openPath: (path) -> rootView.open(path, {@allowActiveEditorChange}) if path @@ -76,7 +76,7 @@ class FuzzyFinderView extends SelectList confirmed : (path) -> return unless path.length - if fs.isFile(project.resolve(path)) + if fs.isFile(path) @cancel() @openPath(path) else @@ -133,11 +133,10 @@ class FuzzyFinderView extends SelectList @miniEditor.setText(currentWord) populateGitStatusPaths: -> - projectRelativePaths = [] - for path, status of git.statuses - continue unless fs.isFile(path) - projectRelativePaths.push(project.relativize(path)) - @setArray(projectRelativePaths) + paths = [] + paths.push(path) for path, status of git.statuses when fs.isFile(path) + + @setArray(paths) populateProjectPaths: (options = {}) -> if @projectPaths?.length > 0 @@ -179,17 +178,10 @@ class FuzzyFinderView extends SelectList else -(editSession.lastOpened or 1) - @paths = _.map editSessions, (editSession) -> - project.relativize editSession.getPath() + @paths = [] + @paths.push(editSession.getPath()) for editSession in editSessions - @setArray(@paths) - - getOpenedPaths: -> - paths = {} - for editSession in project.getEditSessions() - path = editSession.getPath() - paths[path] = editSession.lastOpened if path? - paths + @setArray(_.uniq(@paths)) detach: -> super From 694b499b2143c3f054fdaaf26562405277c3c786 Mon Sep 17 00:00:00 2001 From: John Barnette Date: Thu, 14 Mar 2013 16:53:33 -0700 Subject: [PATCH 2/7] Only relativize stuff under the project root --- src/app/project.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/project.coffee b/src/app/project.coffee index fac99ce8d..f1a6f6634 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -87,6 +87,7 @@ class Project fs.absolute filePath relativize: (fullPath) -> + return fullPath unless fullPath.lastIndexOf(@getPath()) is 0 fullPath.replace(@getPath(), "").replace(/^\//, '') getSoftTabs: -> @softTabs From 74c1e64bdbe79fa324c9a16118574ac9a745fa4b Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 14 Mar 2013 17:40:41 -0700 Subject: [PATCH 3/7] use full paths in meta-t --- src/packages/fuzzy-finder/lib/load-paths-handler.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/packages/fuzzy-finder/lib/load-paths-handler.coffee b/src/packages/fuzzy-finder/lib/load-paths-handler.coffee index ac7c338dc..fcae29e8a 100644 --- a/src/packages/fuzzy-finder/lib/load-paths-handler.coffee +++ b/src/packages/fuzzy-finder/lib/load-paths-handler.coffee @@ -9,14 +9,13 @@ module.exports = paths = [] isIgnored = (path) -> + path = path.substring(rootPath.length + 1) for segment in path.split('/') return true if _.contains(ignoredNames, segment) repo?.isPathIgnored(fs.join(rootPath, path)) onFile = (path) -> - path = path.substring(rootPath.length + 1) paths.push(path) unless isIgnored(path) onDirectory = (path) -> - path = path.substring(rootPath.length + 1) not isIgnored(path) fs.traverseTree(rootPath, onFile, onDirectory) From 7f8978f07a00d3571a6b91bf005b783f6257ec65 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Wed, 27 Mar 2013 19:11:27 -0700 Subject: [PATCH 4/7] absolute paths --- src/packages/fuzzy-finder/lib/load-paths-task.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/fuzzy-finder/lib/load-paths-task.coffee b/src/packages/fuzzy-finder/lib/load-paths-task.coffee index 60a716688..12ef322f9 100644 --- a/src/packages/fuzzy-finder/lib/load-paths-task.coffee +++ b/src/packages/fuzzy-finder/lib/load-paths-task.coffee @@ -15,15 +15,15 @@ class LoadPathsTask paths = [] isIgnored = (path) -> + path = path.substring(rootPath.length + 1) for segment in path.split('/') return true if _.contains(ignoredNames, segment) ignoreGitIgnoredFiles and git?.isPathIgnored(fs.join(rootPath, path)) onFile = (path) -> return if @aborted - path = path.substring(rootPath.length + 1) paths.push(path) unless isIgnored(path) onDirectory = (path) => - not @aborted and not isIgnored(path.substring(rootPath.length + 1)) + not @aborted and not isIgnored(path) onDone = => @callback(paths) unless @aborted From 2e0a6af8caa119f6dcdb13bb8180ee27dffcc2cf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 2 Apr 2013 09:04:42 -0700 Subject: [PATCH 5/7] Add back serializiation of last opened time --- src/packages/fuzzy-finder/lib/fuzzy-finder.coffee | 7 ++++++- src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/packages/fuzzy-finder/lib/fuzzy-finder.coffee b/src/packages/fuzzy-finder/lib/fuzzy-finder.coffee index d90ff497d..0a7db9dc8 100644 --- a/src/packages/fuzzy-finder/lib/fuzzy-finder.coffee +++ b/src/packages/fuzzy-finder/lib/fuzzy-finder.coffee @@ -31,7 +31,12 @@ module.exports = @projectPaths = null serialize: -> - @fuzzyFinderView?.getOpenedPaths() + if @fuzzyFinderView? + paths = {} + for editSession in project.getEditSessions() + path = editSession.getPath() + paths[path] = editSession.lastOpened if path? + paths createView: -> unless @fuzzyFinderView diff --git a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee index 15c89721e..8214adb9a 100644 --- a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee +++ b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee @@ -145,6 +145,7 @@ describe 'FuzzyFinder', -> atom.deactivatePackage('fuzzy-finder') states = _.map atom.getPackageState('fuzzy-finder'), (path, time) -> [ path, time ] + expect(states.length).toBe 3 states = _.sortBy states, (path, time) -> -time paths = [ 'sample-with-tabs.coffee', 'sample.txt', 'sample.js' ] From cb1d9af06eb2968aec5060f7d5a69cdce7024b1a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 2 Apr 2013 09:12:39 -0700 Subject: [PATCH 6/7] Only add folder span if project-relative path isn't empty --- src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee index 07ba5b5ec..19afb5e00 100644 --- a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee +++ b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee @@ -60,8 +60,8 @@ class FuzzyFinderView extends SelectList typeClass = 'text-name' @span fs.base(path), class: "file label #{typeClass}" - if folder = fs.directory(path) - @span " - #{project.relativize(folder)}/", class: 'directory' + if folder = project.relativize(fs.directory(path)) + @span " - #{folder}/", class: 'directory' openPath: (path) -> rootView.open(path, {@allowActiveEditorChange}) if path From 4ce45290228bc6812aeddaf7eab9b528f1eda67c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 2 Apr 2013 09:17:53 -0700 Subject: [PATCH 7/7] Use absolute paths in specs --- src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee index 8214adb9a..3c9a5c6e4 100644 --- a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee +++ b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee @@ -78,8 +78,8 @@ describe 'FuzzyFinder', -> expect(rootView.getActiveView()).toBe editor2 rootView.trigger 'fuzzy-finder:toggle-file-finder' - finderView.confirmed('dir/a') expectedPath = project.resolve('dir/a') + finderView.confirmed(expectedPath) expect(finderView.hasParent()).toBeFalsy() expect(editor1.getPath()).not.toBe expectedPath @@ -189,7 +189,7 @@ describe 'FuzzyFinder', -> describe "when the active pane has an item for the selected path", -> it "switches to the item for the selected path", -> expectedPath = project.resolve('sample.txt') - finderView.confirmed('sample.txt') + finderView.confirmed(expectedPath) expect(finderView.hasParent()).toBeFalsy() expect(editor1.getPath()).not.toBe expectedPath @@ -205,7 +205,7 @@ describe 'FuzzyFinder', -> expect(rootView.getActiveView()).toBe editor1 expectedPath = project.resolve('sample.txt') - finderView.confirmed('sample.txt') + finderView.confirmed(expectedPath) expect(finderView.hasParent()).toBeFalsy() expect(editor1.getPath()).toBe expectedPath @@ -380,7 +380,7 @@ describe 'FuzzyFinder', -> runs -> expect(finderView).not.toBeVisible() - expect(openedPath).toBe "sample.txt" + expect(openedPath).toBe project.resolve("sample.txt") it "displays an error when the word under the cursor doesn't match any files", -> editor.setText("moogoogaipan")