Skip to content
This repository has been archived by the owner on Sep 8, 2018. It is now read-only.

Commit

Permalink
Position decoration at top of line number when the first line is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Jan 16, 2018
1 parent ad83133 commit e63d948
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/git-diff-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ class GitDiffView
if oldLines is 0 and newLines > 0
@markRange(startRow, endRow, 'git-line-added')
else if newLines is 0 and oldLines > 0
@markRange(startRow, startRow, 'git-line-removed')
if startRow < 0
@markRange(0, 0, 'git-previous-line-removed')
else
@markRange(startRow, startRow, 'git-line-removed')
else
@markRange(startRow, endRow, 'git-line-modified')
return
Expand Down
9 changes: 9 additions & 0 deletions spec/git-diff-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ describe "GitDiff package", ->
expect(editorView.querySelectorAll('.git-line-removed').length).toBe 1
expect(editorView.querySelector('.git-line-removed')).toHaveData("buffer-row", 4)

describe "when the editor has removed the first line", ->
it "highlights the line preceeding the deleted lines", ->
expect(editorView.querySelectorAll('.git-line-added').length).toBe 0
editor.setCursorBufferPosition([0, 0])
editor.deleteLine()
advanceClock(editor.getBuffer().stoppedChangingDelay)
expect(editorView.querySelectorAll('.git-previous-line-removed').length).toBe 1
expect(editorView.querySelector('.git-previous-line-removed')).toHaveData("buffer-row", 0)

describe "when a modified line is restored to the HEAD version contents", ->
it "removes the diff highlight", ->
expect(editorView.querySelectorAll('.git-line-modified').length).toBe 0
Expand Down
16 changes: 16 additions & 0 deletions styles/git-diff.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ atom-text-editor {
margin-top: -@size;
pointer-events: none;
}

&.git-previous-line-removed:before {
@size: 4px;

position: absolute;
left: 0;
top: 0;
height: 0;
width: 0;
content: " ";
border: solid transparent;
border-left-color: @syntax-color-removed;
border-width: @size;
margin-top: -@size;
pointer-events: none;
}
}
.gutter.git-diff-icon .line-number {
width: 100%;
Expand Down

0 comments on commit e63d948

Please sign in to comment.