mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Update branch text on save
This commit is contained in:
committed by
Corey Johnson
parent
e4fb12a398
commit
b2b00a7b39
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user