mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Show status icons in fuzzy finder
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user