Skip to content

Commit e58ac38

Browse files
committed
add code folding support to blame
1 parent 945085a commit e58ac38

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

lib/views/blame-list-view.coffee

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,34 @@ BlameListView = React.createClass
119119
error: true
120120
dirty: false
121121
else
122+
data = @prepareDataForCurrentEditorState(data)
122123
@setState
123124
loading: false
124125
error: false
125126
dirty: false
126127
annotations: data
127128

129+
# Modifies the blame data for the current editor state, taking
130+
# folds into account.
131+
# TODO: Handle soft wraps here as well
132+
prepareDataForCurrentEditorState: (originalData) ->
133+
filteredLineData = []
134+
highestScreenRowSeen = 0
135+
e = @editor()
136+
137+
# loop through the blame data and filter out the blame line rows
138+
# for lines that are not visible on the screen due to wrapped code
139+
# TODO: Handle soft wraps here.
140+
# Using each instead of _.filter() since I will need to add empty rows
141+
# for line wraps
142+
_.each originalData, (lineData, index) ->
143+
screenRow = e.screenPositionForBufferPosition([index, 0]).row
144+
if screenRow == index or screenRow > highestScreenRowSeen
145+
filteredLineData.push lineData
146+
highestScreenRowSeen = screenRow
147+
148+
return filteredLineData
149+
128150
# bound callback for Editor 'contents-modified' event
129151
contentsModified: ->
130152
return unless @isMounted()
@@ -137,8 +159,9 @@ BlameListView = React.createClass
137159

138160
# bound callback for Editor 'screen-lines-changed' event
139161
screenLinesChanged: ->
140-
console.log 'screen-lines-changed!'
141-
return
162+
return unless @isMounted()
163+
@loadBlame() if @state.visible
164+
@matchScrollPosition()
142165

143166
toggle: ->
144167
if @state.visible

0 commit comments

Comments
 (0)