Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ikari7789 opened this issue May 9, 2016 · 11 comments
Open
Labels

Comments

@ikari7789
Copy link

[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
Copy link
Contributor

abe33 commented May 9, 2016

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?

@abe33 abe33 added the bug label May 9, 2016
@ikari7789
Copy link
Author

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

@abe33
Copy link
Contributor

abe33 commented May 10, 2016

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
Copy link
Author

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
Copy link
Author

ikari7789 commented May 11, 2016

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
Copy link
Contributor

abe33 commented May 11, 2016

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
Copy link

thorade commented May 11, 2016

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
Copy link

gmmeyer commented May 11, 2016

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
Copy link

AEgan commented May 12, 2016

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 abe33 reopened this May 13, 2016
@abe33
Copy link
Contributor

abe33 commented May 13, 2016

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

abe33 added a commit that referenced this issue May 20, 2016
@jeanrajotte
Copy link

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

abe33 added a commit that referenced this issue May 25, 2016
I hope it’ll provide some insight on what’s happening with #481
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants