Skip to content

Commit 2cc91b8

Browse files
committed
Add support for gutter decorations
As promised in #21
1 parent 761f7b3 commit 2cc91b8

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

lib/minimap-git-diff-binding.coffee

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ class MinimapGitDiffBinding
1616

1717
@editor = @minimap.getTextEditor()
1818

19-
@subscriptions.add @editor.getBuffer().onDidStopChanging @updateDiffs
2019
@subscriptions.add @minimap.onDidDestroy @destroy
2120

2221
if repository = @getRepo()
22+
@subscriptions.add @editor.getBuffer().onDidStopChanging @updateDiffs
2323
@subscriptions.add repository.onDidChangeStatuses =>
2424
@scheduleUpdate()
2525
@subscriptions.add repository.onDidChangeStatus (changedPath) =>
2626
@scheduleUpdate() if changedPath is @editor.getPath()
2727
@subscriptions.add repository.onDidDestroy =>
2828
@destroy()
29+
@subscriptions.add atom.config.observe 'minimap-git-diff.useGutterDecoration', (@useGutterDecoration) =>
30+
@scheduleUpdate()
2931

3032
@scheduleUpdate()
3133

@@ -46,11 +48,11 @@ class MinimapGitDiffBinding
4648
startRow = newStart - 1
4749
endRow = newStart + newLines - 2
4850
if oldLines is 0 and newLines > 0
49-
@markRange(startRow, endRow, '.minimap .git-line-added')
51+
@markRange(startRow, endRow, '.git-line-added')
5052
else if newLines is 0 and oldLines > 0
51-
@markRange(startRow, startRow, '.minimap .git-line-removed')
53+
@markRange(startRow, startRow, '.git-line-removed')
5254
else
53-
@markRange(startRow, endRow, '.minimap .git-line-modified')
55+
@markRange(startRow, endRow, '.git-line-modified')
5456

5557
removeDecorations: ->
5658
return unless @markers?
@@ -60,7 +62,8 @@ class MinimapGitDiffBinding
6062
markRange: (startRow, endRow, scope) ->
6163
return if @editor.displayBuffer.isDestroyed()
6264
marker = @editor.markBufferRange([[startRow, 0], [endRow, Infinity]], invalidate: 'never')
63-
@minimap.decorateMarker(marker, type: 'line', scope: scope, plugin: 'git-diff')
65+
type = if @useGutterDecoration then 'gutter' else 'line'
66+
@minimap.decorateMarker(marker, {type, scope: ".minimap .#{type} #{scope}", plugin: 'git-diff'})
6467
@markers ?= []
6568
@markers.push(marker)
6669

lib/minimap-git-diff.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ MinimapGitDiffBinding = null
44

55
class MinimapGitDiff
66

7+
config:
8+
useGutterDecoration:
9+
type: 'boolean'
10+
default: false
11+
description: 'When enabled the gif diffs will be displayed as thin vertical lines on the left side of the minimap.'
12+
713
pluginActive: false
814
constructor: ->
915
@subscriptions = new CompositeDisposable

styles/minimap-git-diff.less

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,31 @@
66
@import "syntax-variables";
77

88
.minimap {
9-
.git-line-modified{
10-
background: fadeOut(@syntax-color-modified, 50%);
11-
}
9+
.line {
10+
.git-line-modified {
11+
background: fadeOut(@syntax-color-modified, 50%);
12+
}
13+
14+
.git-line-added {
15+
background: fadeOut(@syntax-color-added, 40%);
16+
}
1217

13-
.git-line-added {
14-
background: fadeOut(@syntax-color-added, 40%);
18+
.git-line-removed {
19+
background: fadeOut(@syntax-color-removed, 30%);
20+
}
1521
}
1622

17-
.git-line-removed {
18-
background: fadeOut(@syntax-color-removed, 30%);
23+
.gutter {
24+
.git-line-modified {
25+
background: @syntax-color-modified;
26+
}
27+
28+
.git-line-added {
29+
background: @syntax-color-added;
30+
}
31+
32+
.git-line-removed {
33+
background: @syntax-color-removed;
34+
}
1935
}
2036
}

0 commit comments

Comments
 (0)