mirror of
https://github.com/atom/atom.git
synced 2026-02-04 19:54:59 -05:00
Show diff stat in status bar
Include the number of lines added and removed for new and modified files
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user