Show status icons in fuzzy finder

This commit is contained in:
Kevin Sawicki
2013-02-27 16:31:51 -08:00
parent 68b61d71c6
commit 910be149ab
3 changed files with 70 additions and 14 deletions

View File

@@ -39,19 +39,30 @@ class FuzzyFinderView extends SelectList
itemForElement: (path) ->
$$ ->
@li =>
ext = fs.extension(path)
if fs.isReadmePath(path)
typeClass = 'readme-name'
else if fs.isCompressedExtension(ext)
typeClass = 'compressed-name'
else if fs.isImageExtension(ext)
typeClass = 'image-name'
else if fs.isPdfExtension(ext)
typeClass = 'pdf-name'
else if fs.isBinaryExtension(ext)
typeClass = 'binary-name'
else
typeClass = 'text-name'
typeClass = null
repo = project.repo
if repo?
status = project.repo?.statuses[project.resolve(path)]
if repo.isStatusNew(status)
typeClass = 'new'
else if repo.isStatusModified(status)
typeClass = 'modified'
unless typeClass
ext = fs.extension(path)
if fs.isReadmePath(path)
typeClass = 'readme-name'
else if fs.isCompressedExtension(ext)
typeClass = 'compressed-name'
else if fs.isImageExtension(ext)
typeClass = 'image-name'
else if fs.isPdfExtension(ext)
typeClass = 'pdf-name'
else if fs.isBinaryExtension(ext)
typeClass = 'binary-name'
else
typeClass = 'text-name'
@span fs.base(path), class: "file label #{typeClass}"
if folder = fs.directory(path)
@span " - #{folder}/", class: 'directory'

View File

@@ -376,7 +376,6 @@ describe 'FuzzyFinder', ->
runs ->
expect(finderView.find('.error').text().length).toBeGreaterThan 0
describe "opening a path into a split", ->
beforeEach ->
rootView.attachToDom()
@@ -425,3 +424,37 @@ describe 'FuzzyFinder', ->
expect(editor.splitUp).toHaveBeenCalled()
expect(rootView.getActiveEditor()).not.toBe editor
expect(rootView.getActiveEditor().getPath()).toBe editor.getPath()
describe "git status decorations", ->
[originalText, originalPath, editor, newPath] = []
beforeEach ->
editor = rootView.getActiveEditor()
originalText = editor.getText()
originalPath = editor.getPath()
newPath = project.resolve('newsample.js')
fs.write(newPath, '')
afterEach ->
fs.write(originalPath, originalText)
fs.remove(newPath) if fs.exists(newPath)
describe "when a modified file is shown in the list", ->
it "displays the modified icon", ->
editor.setText('modified')
editor.save()
project.repo?.getPathStatus(editor.getPath())
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
expect(finderView.find('.file.modified').length).toBe 1
expect(finderView.find('.file.modified').text()).toBe 'sample.js'
describe "when a new file is shown in the list", ->
it "displays the new icon", ->
rootView.open('newsample.js')
project.repo?.getPathStatus(editor.getPath())
rootView.trigger 'fuzzy-finder:toggle-buffer-finder'
expect(finderView.find('.file.new').length).toBe 1
expect(finderView.find('.file.new').text()).toBe 'newsample.js'

View File

@@ -16,6 +16,18 @@
color: #9d9d9d;
}
.fuzzy-finder .file.new:before {
position: relative;
top: 1px;
content: "\f06b";
}
.fuzzy-finder .file.modified:before {
position: relative;
top: 1px;
content: "\f06d";
}
.fuzzy-finder .file.text-name:before {
content: "\f011";
}