Update branch text on save

This commit is contained in:
Kevin Sawicki
2012-10-25 13:32:19 -07:00
committed by Corey Johnson
parent e4fb12a398
commit b2b00a7b39

View File

@@ -34,6 +34,7 @@ class StatusBar extends View
@subscribeToBuffer()
@updatePathText()
@updateBranchText()
@updateCursorPositionText()
@editor.on 'cursor-move', => _.defer => @updateCursorPositionText()
@@ -43,8 +44,9 @@ class StatusBar extends View
@buffer?.off '.status-bar'
@buffer = @editor.getBuffer()
@buffer.on 'change.status-bar', => _.defer => @updateBufferModifiedText()
@buffer.on 'after-save.status-bar', => _.defer => @updateBufferModifiedText()
@updateBufferModifiedText()
@buffer.on 'after-save.status-bar', => _.defer =>
@updateBranchText()
@updateBufferModifiedText()
updateBufferModifiedText: ->
if @buffer.isModified()
@@ -52,6 +54,18 @@ class StatusBar extends View
else
@bufferModified.text('')
updateBranchText: ->
if path = @editor.getPath()
@head = Git.open(path)?.getShortHead()
else
@head = null
if @head
@branchArea.show()
@branchLabel.text(@head)
else
@branchArea.hide()
updatePathText: ->
path = @editor.getPath()
if path
@@ -62,9 +76,4 @@ class StatusBar extends View
updateCursorPositionText: ->
{ row, column } = @editor.getCursorBufferPosition()
if @head
@branchArea.show()
@branchLabel.text(@head)
else
@branchArea.hide()
@cursorPosition.text("#{row + 1},#{column + 1}")