@@ -225,26 +225,45 @@ private void DrawTimelineRectAroundIconRect(Rect parentRect, Rect iconRect)
225
225
public void Load ( int loadAhead , List < GitLogEntry > loadEntries )
226
226
{
227
227
var selectedCommitId = SelectedGitLogEntry . CommitID ;
228
+ var scrollValue = scroll . y ;
229
+
230
+ var previousCount = entries . Count ;
231
+
232
+ var scrollIndex = ( int ) ( scrollValue / Styles . HistoryEntryHeight ) ;
228
233
229
234
statusAhead = loadAhead ;
230
235
entries = loadEntries ;
231
236
232
- var changed = false ;
237
+ var selectionPresent = false ;
233
238
for ( var index = 0 ; index < entries . Count ; index ++ )
234
239
{
235
240
var gitLogEntry = entries [ index ] ;
236
241
if ( gitLogEntry . CommitID . Equals ( selectedCommitId ) )
237
242
{
238
243
selectedIndex = index ;
239
- changed = true ;
244
+ selectionPresent = true ;
240
245
break ;
241
246
}
242
247
}
243
248
244
- if ( ! changed )
249
+ if ( ! selectionPresent )
245
250
{
246
251
selectedIndex = - 1 ;
247
252
}
253
+
254
+ if ( scrollIndex > entries . Count )
255
+ {
256
+ ScrollTo ( 0 ) ;
257
+ }
258
+ else
259
+ {
260
+ var scrollOffset = scrollValue % Styles . HistoryEntryHeight ;
261
+
262
+ var scrollIndexFromBottom = previousCount - scrollIndex ;
263
+ var newScrollIndex = entries . Count - scrollIndexFromBottom ;
264
+
265
+ ScrollTo ( newScrollIndex , scrollOffset ) ;
266
+ }
248
267
}
249
268
250
269
private int SelectNext ( int index )
@@ -279,9 +298,9 @@ private int SelectPrevious(int index)
279
298
return index ;
280
299
}
281
300
282
- public void ScrollTo ( int index )
301
+ public void ScrollTo ( int index , float offset = 0f )
283
302
{
284
- scroll . Set ( scroll . x , Styles . HistoryEntryHeight * index ) ;
303
+ scroll . Set ( scroll . x , Styles . HistoryEntryHeight * index + offset ) ;
285
304
}
286
305
}
287
306
0 commit comments