atom-minimap / minimap

A preview of the full source code.
https://atom.io/packages/minimap
MIT License
646 stars 129 forks source link

Uncaught TypeError: this.tokenLinesForScreenRows is not a function #481

Open ikari7789 opened 8 years ago

ikari7789 commented 8 years ago

[Enter steps to reproduce below:]

  1. Just updated Atom (1.7.2 -> 1.7.3) and restarted.

Atom Version: 1.7.3 System: Mac OS X 10.11.4 Thrown From: minimap package, v4.23.5

Stack Trace

Uncaught TypeError: this.tokenLinesForScreenRows is not a function

At /Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js:486

TypeError: this.tokenLinesForScreenRows is not a function
    at atom-text-editor-minimap.drawLines (/Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js:486:29)
    at atom-text-editor-minimap.redrawRangesOnLayer (/Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js:270:14)
    at atom-text-editor-minimap.updateTokensLayer (/Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js:136:10)
    at atom-text-editor-minimap.updateCanvas (/Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js:104:10)
    at atom-text-editor-minimap.update (/Users/andrew.miller/.atom/packages/minimap/lib/minimap-element.js:846:10)
    at /Users/andrew.miller/.atom/packages/minimap/lib/minimap-element.js:740:12

Commands

Config

{
  "core": {
    "disabledPackages": [
      "linter-perl-check-syntax"
    ],
    "ignoredNames": [
      ".git",
      ".DS_Store",
      ".vagrant"
    ]
  },
  "minimap": {
    "plugins": {
      "git-diff": false,
      "git-diffDecorationsZIndex": 0
    }
  }
}

Installed Packages

# User
Sublime-Style-Column-Selection, v1.5.1
color-picker, v2.1.1
docblockr, v0.7.3
editorconfig, v1.4.1
git-diff-details, v1.3.0
language-perl-html-template, v1.0.2
language-perl-template-toolkit, v0.1.0
language-puppet, v0.19.1
linter, v1.11.4
linter-perlcritic, v0.3.3
minimap, v4.23.5
minimap-git-diff, v4.3.1
perltidy, v2.2.0
php-debug, v0.2.3
pigments, v0.26.2
pretty-json, v1.0.3
project-manager, v2.9.7
ssh-config, v0.10.1

# Dev
No dev packages
abe33 commented 8 years ago

Hi @ikari7789, that's weird, because the function definitely exist (https://github.com/atom-minimap/minimap/blob/master/lib/mixins/canvas-drawer.js#L413-L460) it looks like you're still running the old code after updating the package from within Atom, can you confirm it?

ikari7789 commented 8 years ago

How could I confirm it? Sorry, I'm not very familiar with the plugin system in Atom beyond the GUI.

abe33 commented 8 years ago

You can find the source of all the package you have installed in ~/.atom/packages, so there should be a tokenLinesForScreenRows in the lib/mixins/canvas-drawer.js file of the minimap package.

If I guess correctly the file should have the method, and restarting/reloading Atom should solve this issue.

ikari7789 commented 8 years ago

It is there in my package and I'm no longer receiving the error message. If it pops up again I'll make a new ticket. Thanks for the help!

ikari7789 commented 8 years ago

Actually... It just happened again and I've definitely restarted Atom several times. I'm not sure what could be causing it. It doesn't seem to happen on small files, but has been popping up on large files, the one I'm using to test with in particular is 33,880 lines. The error pops up when I reach the bottom of the file.

P35040:~ andrew.miller$ grep --line-number --context=5 --color=always 'tokenLinesForScreenRows' /Users/andrew.miller/.atom/packages/minimap/lib/mixins/canvas-drawer.js
408-   * @param  {number} startRow The start row
409-   * @param  {number} endRow The end row
410-   * @return {Array<Array>} An array of tokens by line
411-   * @access private
412-   */
413:  tokenLinesForScreenRows (startRow, endRow) {
414-    const editor = this.getTextEditor()
415-    let tokenLines = []
416-    if (typeof editor.tokenizedLinesForScreenRows === 'function') {
417-      for (let tokenizedLine of editor.tokenizedLinesForScreenRows(startRow, endRow)) {
418-        if (tokenizedLine) {
--
--
481-    const displayCodeHighlights = this.displayCodeHighlights
482-    const context = this.tokensLayer.context
483-    const {width: canvasWidth} = this.tokensLayer.getSize()
484-
485-    let y = offsetRow * lineHeight
486:    for (let tokens of this.tokenLinesForScreenRows(firstRow, lastRow)) {
487-      let x = 0
488-      context.clearRect(x, y, canvasWidth, lineHeight)
489-      for (let token of tokens) {
490-        if (/^\s+$/.test(token.value)) {
491-          x += token.value.length * charWidth
abe33 commented 8 years ago

That's really weird, but thanks for the investigation, I'll see if I can at least add some guards against this issue. Maybe it's just that the function is called with another context object that isn't a minimap element instance.

thorade commented 8 years ago

Same issue here, find stack trace below:

/C:/Users/mthorade/.atom/packages/minimap/lib/mixins/canvas-drawer.js:588
Hide Stack Trace
TypeError: this.tokenLinesForScreenRows is not a function
    at atom-text-editor-minimap.drawLines (C:/Users/mthorade/.atom/packages/minimap/lib/mixins/canvas-drawer.js:486:29)
    at atom-text-editor-minimap.redrawRangesOnLayer (C:/Users/mthorade/.atom/packages/minimap/lib/mixins/canvas-drawer.js:270:14)
    at atom-text-editor-minimap.updateTokensLayer (C:/Users/mthorade/.atom/packages/minimap/lib/mixins/canvas-drawer.js:136:10)
    at atom-text-editor-minimap.updateCanvas (C:/Users/mthorade/.atom/packages/minimap/lib/mixins/canvas-drawer.js:104:10)
    at atom-text-editor-minimap.update (C:/Users/mthorade/.atom/packages/minimap/lib/minimap-element.js:846:10)
    at C:/Users/mthorade/.atom/packages/minimap/lib/minimap-element.js:740:12

This happened when opening a 40K lines html file.

(Atom 1.7.3, minimap 4.23.5, Windows 10 64bit)

gmmeyer commented 8 years ago

I get this, too. But it only happens to me when scrolling down to the end of a large file. (A file that's well over 1000 lines).

AEgan commented 8 years ago

I get this, too. But it only happens to me when scrolling down to the end of a large file. (A file that's well over 1000 lines).

☝️ I've seen this with one file, which has over 12k lines, and it comes up after minimap reaches the very bottom of the file and can't scroll any further. I'm not familiar with the code but thought I would add some color after seeing this issue.

abe33 commented 8 years ago

I've reopened the issue. Sorry for the delay, I'll plan to work on this during this week-end.

jeanrajotte commented 8 years ago

FYI, the latest update (4.24.0) still has this defect.