         atom.grammars.grammarForScopeName 'text.plain.null-grammar'
 
     minimapElement.addEventListener 'mousemove', mousemove = (event) =>
+      textEditor = minimap.getTextEditor()
+
       # get the offset in lines
       offsetY = event.offsetY
       lineHeight = minimap.charHeight + minimap.interline

      else atom.workspace.addBottomPanel @codeglanceView

    @disposables.add new Disposable =>
      @codeglanceView.destroy()
      @panel?.destroy()
      [@panel, @codeglanceView] = []


      # select nLines / 2 lines before and after the cursorLine
      nLines = atom.config.get 'minimap-codeglance.numberOfLines'
      firstLine = cursorLine - Math.floor(nLines / 2)
      lastLine = cursorLine + Math.ceil(nLines / 2)

      if firstLine > textEditor.getLastScreenRow()
        @panel.hide()
        return

      lines = []
      for line in [firstLine...lastLine]
        lines.push textEditor.lineTextForScreenRow(line) ? ''
      text = lines.join '\n'

      @codeglanceView.setText text
      @panel.show()

    minimapElement.addEventListener 'mouseleave', mouseleave = =>
      @panel.hide()
