Skip to content
This repository was archived by the owner on Sep 8, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 17 additions & 5 deletions styles/git-diff.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ atom-text-editor {
padding-left: ~"calc(0.5em - 2px)";
}

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

@size: 4px;
&.git-line-removed:before,
&.git-previous-line-removed:before {
position: absolute;
left: 0;
bottom: -@size;
height: 0;
width: 0;
content: " ";
Expand All @@ -29,7 +28,14 @@ atom-text-editor {
margin-top: -@size;
pointer-events: none;
}
&.git-line-removed:before {
bottom: -@size;
}
&.git-previous-line-removed:before {
top: 0;
}
}

.gutter.git-diff-icon .line-number {
width: 100%;
border-left: none;
Expand Down Expand Up @@ -59,12 +65,18 @@ atom-text-editor {
color: @syntax-color-added;
}

&.git-line-removed:before {
&.git-line-removed:before,
&.git-previous-line-removed:before {
border: none; // reset triangle
content: @dash;
color: @syntax-color-removed;
position: relative;
}
&.git-line-removed:before {
top: .6em;
}
&.git-previous-line-removed:before {
top: -.6em;
}
}
}