mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Update status class when window gains focus
This will keep the tree view in sync when Git operations are performed outside of the editor.
This commit is contained in:
@@ -887,6 +887,13 @@ describe "TreeView", ->
|
||||
it "adds a custom style", ->
|
||||
expect(treeView.find('.file:contains(tree-view.txt)')).toHaveClass 'modified'
|
||||
|
||||
describe "when the window gains focus after the contents are restored to a clean state", ->
|
||||
it "removes the custom style", ->
|
||||
expect(treeView.find('.file:contains(tree-view.txt)')).toHaveClass 'modified'
|
||||
fs.write modifiedFile, originalFileContent
|
||||
$(window).trigger 'focus'
|
||||
expect(treeView.find('.file:contains(tree-view.txt)')).not.toHaveClass 'modified'
|
||||
|
||||
describe "when a file is new", ->
|
||||
it "adds a custom style", ->
|
||||
expect(treeView.find('.file:contains(.gitignore)')).toHaveClass 'new'
|
||||
|
||||
@@ -9,13 +9,14 @@ class FileView extends View
|
||||
@content: ({file} = {}) ->
|
||||
@li class: 'file entry', =>
|
||||
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
||||
@span "", class: 'highlight'
|
||||
@span '', class: 'highlight'
|
||||
|
||||
file: null
|
||||
|
||||
initialize: ({@file, project} = {}) ->
|
||||
path = @getPath()
|
||||
extension = fs.extension(path)
|
||||
initialize: ({@file, @project} = {}) ->
|
||||
@subscribe $(window), 'focus', => @updateStatus()
|
||||
|
||||
extension = fs.extension(@getPath())
|
||||
if fs.isCompressedExtension(extension)
|
||||
@fileName.addClass('compressed-name')
|
||||
else if fs.isImageExtension(extension)
|
||||
@@ -25,11 +26,16 @@ class FileView extends View
|
||||
else
|
||||
@fileName.addClass('text-name')
|
||||
|
||||
if project.repo.isPathIgnored(path)
|
||||
@updateStatus()
|
||||
|
||||
updateStatus: ->
|
||||
path = @getPath()
|
||||
@removeClass('ignored modified new')
|
||||
if @project.repo.isPathIgnored(path)
|
||||
@addClass('ignored')
|
||||
else if project.repo.isPathModified(path)
|
||||
else if @project.repo.isPathModified(path)
|
||||
@addClass('modified')
|
||||
else if project.repo.isPathNew(path)
|
||||
else if @project.repo.isPathNew(path)
|
||||
@addClass('new')
|
||||
|
||||
getPath: ->
|
||||
|
||||
Reference in New Issue
Block a user