mirror of
https://github.com/atom/atom.git
synced 2026-02-13 16:14:59 -05:00
Add octicons to fuzzy-finder
Also place file base name first followed by directory path in darker color
This commit is contained in:
@@ -2,6 +2,7 @@ RootView = require 'root-view'
|
||||
FuzzyFinder = require 'fuzzy-finder'
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
fs = require 'fs'
|
||||
|
||||
describe 'FuzzyFinder', ->
|
||||
[rootView, finder] = []
|
||||
@@ -56,7 +57,7 @@ describe 'FuzzyFinder', ->
|
||||
runs ->
|
||||
expect(finder.list.children('li').length).toBe paths.length, finder.maxResults
|
||||
for path in paths
|
||||
expect(finder.list.find("li:contains(#{path})")).toExist()
|
||||
expect(finder.list.find("li:contains(#{fs.base(path)})")).toExist()
|
||||
expect(finder.list.children().first()).toHaveClass 'selected'
|
||||
expect(finder.find(".loading")).not.toBeVisible()
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
SelectList = require 'select-list'
|
||||
_ = require 'underscore'
|
||||
$ = require 'jquery'
|
||||
fs = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class FuzzyFinder extends SelectList
|
||||
@@ -25,7 +26,20 @@ class FuzzyFinder extends SelectList
|
||||
@projectPaths = null
|
||||
|
||||
itemForElement: (path) ->
|
||||
$$ -> @li path
|
||||
$$ ->
|
||||
@li =>
|
||||
ext = fs.extension(path)
|
||||
if fs.isCompressedExtension(ext)
|
||||
typeClass = 'compressed-name'
|
||||
else if fs.isImageExtension(ext)
|
||||
typeClass = 'image-name'
|
||||
else if fs.isPdfExtension(ext)
|
||||
typeClass = 'pdf-name'
|
||||
else
|
||||
typeClass = 'text-name'
|
||||
@span fs.base(path), class: "file #{typeClass}"
|
||||
if folder = fs.directory(path)
|
||||
@span "- #{folder}/", class: 'directory'
|
||||
|
||||
confirmed : (path) ->
|
||||
return unless path.length
|
||||
|
||||
@@ -2,29 +2,10 @@
|
||||
$ = require 'jquery'
|
||||
Git = require 'git'
|
||||
fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class FileView extends View
|
||||
|
||||
@COMPRESSED_EXTENSIONS: [
|
||||
'.gz'
|
||||
'.jar'
|
||||
'.tar'
|
||||
'.zip'
|
||||
]
|
||||
|
||||
@IMAGE_EXTENSIONS: [
|
||||
'.gif'
|
||||
'.jpeg'
|
||||
'.jpg'
|
||||
'.png'
|
||||
]
|
||||
|
||||
@PDF_EXTENSIONS: [
|
||||
'.pdf'
|
||||
]
|
||||
|
||||
@content: (file) ->
|
||||
@li class: 'file entry', =>
|
||||
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
||||
@@ -35,11 +16,11 @@ class FileView extends View
|
||||
initialize: (@file) ->
|
||||
path = @getPath()
|
||||
extension = fs.extension(path)
|
||||
if _.contains(FileView.COMPRESSED_EXTENSIONS, extension)
|
||||
if fs.isCompressedExtension(extension)
|
||||
@fileName.addClass('compressed-name')
|
||||
else if _.contains(FileView.IMAGE_EXTENSIONS, extension)
|
||||
else if fs.isImageExtension(extension)
|
||||
@fileName.addClass('image-name')
|
||||
else if _.contains(FileView.PDF_EXTENSIONS, extension)
|
||||
else if fs.isPdfExtension(extension)
|
||||
@fileName.addClass('pdf-name')
|
||||
else
|
||||
@fileName.addClass('text-name')
|
||||
|
||||
@@ -123,3 +123,24 @@ module.exports =
|
||||
|
||||
md5ForPath: (path) ->
|
||||
$native.md5ForPath(path)
|
||||
|
||||
isCompressedExtension: (ext) ->
|
||||
_.contains([
|
||||
'.gz'
|
||||
'.jar'
|
||||
'.tar'
|
||||
'.zip'
|
||||
], ext)
|
||||
|
||||
isImageExtension: (ext) ->
|
||||
_.contains([
|
||||
'.gif'
|
||||
'.jpeg'
|
||||
'.jpg'
|
||||
'.png'
|
||||
], ext)
|
||||
|
||||
isPdfExtension: (ext) ->
|
||||
_.contains([
|
||||
'.pdf'
|
||||
], ext)
|
||||
|
||||
Reference in New Issue
Block a user