   atom.config.get('git-plus.amountOfCommitsToShow')
 
 module.exports =
-class LogListView extends ScrollView
+class LogListView extends View
   @content: ->
     @div class: 'git-plus-log native-key-bindings', tabindex: -1, =>
       @table id: 'git-plus-commits', outlet: 'commitsListView'

  getTitle: -> 'git-plus: Log'

  initialize: ->
    super
    @skipCommits = 0
    @on 'click', '.commit-row', ({currentTarget}) =>
      @showCommitLog currentTarget.getAttribute('hash')
    @scroll =>
      @getLog() if @scrollTop() + @height() is @prop('scrollHeight')

  parseData: (data) ->
    if data.length > 0

    args.push @currentFile if @onlyCurrentFile and @currentFile?
    git.cmd(args, cwd: @repo.getWorkingDirectory())
    .then (data) => @parseData data

  selectFirstResult: ->
    @selectResult(@find('.commit-row:first'))
    @scrollToTop()

  selectLastResult: ->
    @selectResult(@find('.commit-row:last'))
    @scrollToBottom()

  selectNextResult: (skip = 1) ->
    selectedView = @find('.selected')
    return @selectFirstResult() if selectedView.length < 1
    nextView = @getNextResult(selectedView, skip)

    @selectResult(nextView)
    @scrollTo(nextView)

  selectPreviousResult: (skip = 1) ->
    selectedView = @find('.selected')
    return @selectFirstResult() if selectedView.length < 1
    prevView = @getPreviousResult(selectedView, skip)

    @selectResult(prevView)
    @scrollTo(prevView)

  getNextResult: (element, skip) ->
    return unless element?.length
    items = @find('.commit-row')
    itemIndex = items.index(element)
    $(items[Math.min(itemIndex + skip, items.length - 1)])

  getPreviousResult: (element, skip) ->
    return unless element?.length
    items = @find('.commit-row')
    itemIndex = items.index(element)
    $(items[Math.max(itemIndex - skip, 0)])

  selectResult: (resultView) ->
    return unless resultView?.length
    @find('.selected').removeClass('selected')
    resultView.addClass('selected')

  scrollTo: (element) ->
    return unless element?.length
    top = @scrollTop() + element.offset().top - @offset().top
    bottom = top + element.outerHeight()

    @scrollBottom(bottom) if bottom > @scrollBottom()
    @scrollTop(top) if top < @scrollTop()
