Show diff stat in status bar

Include the number of lines added and removed for
new and modified files
This commit is contained in:
Kevin Sawicki
2012-12-27 10:41:02 -08:00
parent 747b2b6bad
commit 219aaca0f5
6 changed files with 108 additions and 4 deletions

View File

@@ -166,3 +166,12 @@ describe "StatusBar", ->
fs.write(path, originalPathText)
$(window).trigger 'focus'
expect(statusBar.gitStatusIcon).not.toHaveClass('modified-status-icon')
it "displays the diff stat for modified files", ->
fs.write(path, "i've changed for the worse")
rootView.open(path)
expect(statusBar.gitStatusIcon).toHaveText('+1,-1')
it "displays the diff stat for new files", ->
rootView.open(newPath)
expect(statusBar.gitStatusIcon).toHaveText('+1')

View File

@@ -79,8 +79,18 @@ class StatusBar extends View
@gitStatusIcon.removeClass().addClass('git-status octicons')
if @buffer.getGit()?.isPathModified(path)
@gitStatusIcon.addClass('modified-status-icon')
else if @buffer.getGit()?.isPathNew(path)
stats = @buffer.getGit().getDiffStats(path)
if stats.added and stats.deleted
@gitStatusIcon.text("+#{stats.added},-#{stats.deleted}")
else if stats.added
@gitStatusIcon.text("+#{stats.added}")
else if stats.deleted
@gitStatusIcon.text("-#{stats.deleted}")
else
@gitStatusIcon.text('')
else if @buffer.getGit()?.isPathNew(path)
@gitStatusIcon.addClass('new-status-icon')
@gitStatusIcon.text("+#{@buffer.getLineCount()}")
updatePathText: ->
if path = @editor.getPath()