mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Merge branch 'absolute-paths-in-fuzzy-finder'
This commit is contained in:
@@ -75,6 +75,7 @@ class Project
|
||||
fs.absolute filePath
|
||||
|
||||
relativize: (fullPath) ->
|
||||
return fullPath unless fullPath.lastIndexOf(@getPath()) is 0
|
||||
fullPath.replace(@getPath(), "").replace(/^\//, '')
|
||||
|
||||
getSoftTabs: -> @softTabs
|
||||
|
||||
@@ -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)
|
||||
@@ -60,7 +60,7 @@ class FuzzyFinderView extends SelectList
|
||||
typeClass = 'text-name'
|
||||
|
||||
@span fs.base(path), class: "file label #{typeClass}"
|
||||
if folder = fs.directory(path)
|
||||
if folder = project.relativize(fs.directory(path))
|
||||
@span " - #{folder}/", class: 'directory'
|
||||
|
||||
openPath: (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?
|
||||
@@ -173,17 +172,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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' ]
|
||||
@@ -188,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
|
||||
@@ -204,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
|
||||
@@ -379,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")
|
||||
|
||||
Reference in New Issue
Block a user