camel-chased / editor-background

Background image/animation for atom text editor
MIT License
37 stars 15 forks source link

Uncaught TypeError: Cannot read property 'text' of undefined #26

Closed a7madgamal closed 7 years ago

a7madgamal commented 8 years ago

[Enter steps to reproduce below:]

  1. opened new tab
  2. pasted some js
  3. changed the grammer from the status bar to javascript
  4. got the error but all seems to work normally

Atom Version: 1.10.2 Electron Version: 0.37.8 System: Mac OS X 10.11.6 Thrown From: editor-background package, v1.2.23

Stack Trace

Uncaught TypeError: Cannot read property 'text' of undefined

At /Users/mido/.atom/packages/editor-background/lib/editor-background.coffee:617

TypeError: Cannot read property 'text' of undefined
    at Object.module.exports.EditorBackground.drawLine (/Users/mido/.atom/packages/editor-background/lib/editor-background.coffee:617:25)
    at Object.module.exports.EditorBackground.drawLines (/Users/mido/.atom/packages/editor-background/lib/editor-background.coffee:732:16)
    at Object.module.exports.EditorBackground.drawBackground (/Users/mido/.atom/packages/editor-background/lib/editor-background.coffee:793:18)
    at /Users/mido/.atom/packages/editor-background/lib/editor-background.coffee:801:23
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:346:32
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/node_modules/event-kit/lib/emitter.js:129:28)
    at DisplayLayer.module.exports.DisplayLayer.emitDidChangeSyncEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/display-layer.js:366:27)
    at DisplayLayer.module.exports.DisplayLayer.reset (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/display-layer.js:227:12)
    at TextEditor.module.exports.TextEditor.resetDisplayLayer (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:368:32)
    at TextEditor.module.exports.TextEditor.subscribeToScopedConfigSettings (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:336:19)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:3:61
    at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
    at TokenizedBuffer.module.exports.TokenizedBuffer.setGrammar (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-buffer.js:193:27)
    at TextEditor.module.exports.TextEditor.setGrammar (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:2732:35)
    at GrammarListView.module.exports.GrammarListView.confirmed (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/grammar-selector/lib/grammar-list-view.js:60:21)
    at GrammarListView.module.exports.SelectListView.confirmSelection (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21)
    at HTMLLIElement.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:139:19)
    at HTMLOListElement.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
    at HTMLOListElement.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)

Commands

     -7:19.4.0 editor:newline (atom-text-editor.editor.is-focused)
     -7:18.3.0 core:move-up (atom-text-editor.editor.is-focused)
     -7:17.2.0 core:paste (atom-text-editor.editor.is-focused.hyperclick)
     -7:16.1.0 editor:newline (atom-text-editor.editor.is-focused)
     -6:38.9.0 core:backspace (atom-text-editor.editor.is-focused)
     -5:53.1.0 core:copy (atom-text-editor.editor.is-focused.hyperclick)
     -5:49.7.0 editor:newline (atom-text-editor.editor.is-focused)
     -5:43.7.0 core:backspace (atom-text-editor.editor.is-focused)
  3x -1:13.4.0 editor:newline (atom-text-editor.editor.is-focused)
     -1:11.7.0 core:paste (atom-text-editor.editor.is-focused.hyperclick)
     -1:08.0 editor:toggle-line-comments (atom-text-editor.editor.is-focused)
     -1:06.5.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:09.9.0 application:new-file (atom-text-editor.editor.is-focused.hyperclick)
     -0:09.8.0 tree-view:reveal-active-file (atom-workspace.workspace.scrollbars-visible-always.seti-ui-no-icons.theme-gruvbox-plus-syntax.theme-slim-dark-ui.editor-background)
     -0:08.8.0 core:paste (atom-text-editor.editor.is-focused.hyperclick)
     -0:04.9.0 grammar-selector:show (atom-text-editor.editor)

Config

{
  "core": {
    "audioBeep": false,
    "disabledPackages": [
      "highlight-column",
      "linter-js-standard",
      "grammar-tab-colors",
      "minimap-autohide",
      "autohide-tree-view",
      "multirow-tabs",
      "tree-view-git-status",
      "chary-tree-view",
      "language-dotenv",
      "method-separator",
      "minimap-codeglance",
      "minimap-split-diff",
      "source-preview-pug",
      "useful-context-menu",
      "atom-pair",
      "source-preview",
      "tab-smart-sort",
      "git-status",
      "atom-ternjs"
    ],
    "openEmptyEditorOnStart": false,
    "projectHome": "/Users/mido/projects",
    "themes": [
      "slim-dark-ui",
      "gruvbox-plus-syntax"
    ]
  },
  "editor-background": {
    "box3d": {},
    "image": {
      "backgroundSize": "100%",
      "opacity": 30,
      "overlayColor": {
        "red": 0,
        "green": 0,
        "blue": 0,
        "alpha": 1
      },
      "url": "/Users/mido/Downloads/_AHMED/old-paper-2.jpg"
    },
    "other": {
      "treeViewOpacity": 10
    },
    "text": {
      "blur": 1,
      "color": {
        "red": 0,
        "green": 0,
        "blue": 0,
        "alpha": 1
      },
      "expand": 1,
      "opacity": 1
    },
    "video": {}
  }
}

Installed Packages

# User
activate-power-mode, v0.8.1 (active)
atom-beautify, v0.29.11 (inactive)
atom-jade, v0.3.0 (active)
atom-material-syntax-dark, v0.2.5 (inactive)
atom-material-ui, v1.3.6 (inactive)
atom-pair, v2.0.10 (inactive)
atom-ternjs, v0.15.0 (inactive)
autocomplete-html-entities, v0.1.0 (active)
autocomplete-json, v5.1.0 (active)
autocomplete-modules, v1.6.3 (active)
autocomplete-paths, v1.0.2 (active)
autocomplete-ruby, v0.1.0 (active)
autohide-tree-view, v0.25.1 (inactive)
chary-tree-view, v0.2.3 (inactive)
clear-syntax, v0.6.0 (inactive)
coral-blue-syntax, v0.2.0 (inactive)
ctrl-last-tab, v0.3.0 (active)
dark-flat-ui, v1.2.4 (inactive)
dracula-theme, v1.2.8 (inactive)
editor-background, v1.2.23 (active)
editor-stats, v0.17.0 (active)
editorconfig, v1.4.1 (active)
file-icons, v1.7.19 (active)
file-types, v0.5.4-p1 (active)
fonts, v1.6.0 (active)
git-blame, v0.4.11 (inactive)
git-diff-details, v1.3.0 (active)
git-status, v0.3.4 (inactive)
git-time-machine, v1.5.3 (inactive)
goto-last-edit, v0.3.2 (active)
gruvbox-plus-syntax, v1.2.5 (active)
highlight-column, v0.5.1 (inactive)
highlight-selected, v0.11.2 (active)
hyperclick, v0.0.38 (active)
incremental-search, v5.1.0 (inactive)
js-hyperclick, v1.5.0 (active)
language-dots, v0.0.4 (active)
language-pug, v0.0.17 (active)
last-cursor-position, v0.9.0 (active)
linter, v1.11.16 (active)
linter-coffeelint, v1.1.2 (active)
linter-pug-lint, v0.2.0 (active)
method-separator, v0.1.4 (inactive)
minimap, v4.25.0 (active)
minimap-autohide, v0.10.1 (inactive)
minimap-find-and-replace, v4.5.1 (active)
minimap-git-diff, v4.3.1 (active)
minimap-highlight-selected, v4.4.0 (active)
monokai, v0.18.0 (inactive)
open-in-browser, v0.4.7 (inactive)
open-recent, v5.0.0 (active)
outlander-syntax, v1.1.0 (inactive)
package-list, v0.1.2 (inactive)
package-sync, v1.1.0 (active)
path-hyperclick, v0.3.0 (active)
pigments, v0.34.0 (active)
polaris-syntax, v0.1.0 (inactive)
pretty-json, v1.6.0 (active)
project-manager, v3.2.1 (active)
robin-hood-syntax, v1.0.0 (inactive)
seti-syntax, v1.0.1 (inactive)
seti-ui, v1.3.2 (inactive)
simple-drag-drop-text, v0.3.1 (active)
slim-dark-ui, v0.12.0 (active)
source-preview, v0.5.0 (inactive)
source-preview-pug, v0.2.0 (inactive)
split-diff, v1.0.4 (inactive)
synced-sidebar, v0.4.3 (active)
tab-smart-sort, v0.1.4 (inactive)
terminal-plus, v0.14.5 (active)
twilight-syntax, v0.7.0 (inactive)
useful-context-menu, v0.6.0 (inactive)
vertical-tabs, v0.4.1 (active)
atom-dark-syntax, v0.27.0 (inactive)
atom-dark-ui, v0.52.0 (inactive)
atom-light-syntax, v0.28.0 (inactive)
atom-light-ui, v0.44.0 (inactive)
base16-tomorrow-dark-theme, v1.1.0 (inactive)
base16-tomorrow-light-theme, v1.1.1 (inactive)
one-dark-ui, v1.5.0 (inactive)
one-light-ui, v1.5.0 (inactive)
one-dark-syntax, v1.3.0 (inactive)
one-light-syntax, v1.3.0 (inactive)
solarized-dark-syntax, v1.0.2 (inactive)
solarized-light-syntax, v1.0.2 (inactive)
about, v1.5.3 (active)
archive-view, v0.61.1 (active)
autocomplete-atom-api, v0.10.0 (active)
autocomplete-css, v0.11.2 (active)
autocomplete-html, v0.7.2 (active)
autocomplete-plus, v2.31.1 (active)
autocomplete-snippets, v1.11.0 (active)
autoflow, v0.27.0 (inactive)
autosave, v0.23.1 (active)
background-tips, v0.26.1 (active)
bookmarks, v0.41.0 (active)
bracket-matcher, v0.82.1 (active)
command-palette, v0.38.0 (inactive)
deprecation-cop, v0.54.1 (active)
dev-live-reload, v0.47.0 (active)
encoding-selector, v0.22.0 (active)
exception-reporting, v0.39.0 (active)
find-and-replace, v0.201.0 (inactive)
fuzzy-finder, v1.3.0 (active)
git-diff, v1.1.0 (active)
go-to-line, v0.31.0 (inactive)
grammar-selector, v0.48.1 (active)
image-view, v0.58.2 (active)
incompatible-packages, v0.26.1 (active)
keybinding-resolver, v0.35.0 (active)
line-ending-selector, v0.5.0 (active)
link, v0.31.1 (inactive)
markdown-preview, v0.158.0 (active)
metrics, v0.53.1 (active)
notifications, v0.65.0 (active)
open-on-github, v1.2.0 (inactive)
package-generator, v1.0.0 (inactive)
settings-view, v0.242.2 (active)
snippets, v1.0.2 (active)
spell-check, v0.67.1 (active)
status-bar, v1.4.1 (active)
styleguide, v0.47.0 (active)
symbols-view, v0.113.0 (inactive)
tabs, v0.100.2 (active)
timecop, v0.33.2 (active)
tree-view, v0.208.2 (active)
update-package-dependencies, v0.10.0 (active)
welcome, v0.34.0 (active)
whitespace, v0.33.0 (active)
wrap-guide, v0.38.1 (active)
language-c, v0.52.1 (active)
language-clojure, v0.21.0 (active)
language-coffee-script, v0.47.2 (active)
language-csharp, v0.12.1 (active)
language-css, v0.37.1 (active)
language-gfm, v0.88.0 (active)
language-git, v0.15.0 (active)
language-go, v0.42.1 (active)
language-html, v0.45.1 (active)
language-hyperlink, v0.16.0 (active)
language-java, v0.23.0 (active)
language-javascript, v0.119.0 (active)
language-json, v0.18.2 (active)
language-less, v0.29.5 (active)
language-make, v0.22.2 (active)
language-mustache, v0.13.0 (active)
language-objective-c, v0.15.1 (active)
language-perl, v0.35.0 (active)
language-php, v0.37.2 (active)
language-property-list, v0.8.0 (active)
language-python, v0.45.0 (active)
language-ruby, v0.69.0 (active)
language-ruby-on-rails, v0.25.0 (active)
language-sass, v0.56.0 (active)
language-shellscript, v0.22.4 (active)
language-source, v0.9.0 (active)
language-sql, v0.23.0 (active)
language-text, v0.7.1 (active)
language-todo, v0.28.0 (active)
language-toml, v0.18.0 (active)
language-xml, v0.34.9 (active)
language-yaml, v0.26.0 (active)

# Dev
No dev packages
camel-chased commented 7 years ago

should be all right now :)

yyny commented 7 years ago

I still get the same error :(

camel-chased commented 7 years ago

I've tested it on win/lin on different computers and there is no error :/ @YoYoYonnY you are working on Mac? the error comes when you are trying to reproduce error with steps in original post? or some other way? :)

yyny commented 7 years ago
  1. Open Atom
  2. Get Editor-Background to work by opening a (new) file
  3. Change Syntax
  4. :(
yyny commented 7 years ago

Here's the new stack trace:

TypeError: Cannot read property 'text' of undefined
    at Object.module.exports.EditorBackground.drawLine (/home/yyny/.atom/packages/editor-background/lib/editor-background.coffee:612:25)
    at Object.module.exports.EditorBackground.drawLines (/home/yyny/.atom/packages/editor-background/lib/editor-background.coffee:727:16)
    at Object.module.exports.EditorBackground.drawBackground (/home/yyny/.atom/packages/editor-background/lib/editor-background.coffee:796:18)
    at /home/yyny/.atom/packages/editor-background/lib/editor-background.coffee:804:23
    at Function.module.exports.Emitter.simpleDispatch (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
    at /usr/share/atom/resources/app.asar/src/text-editor.js:346:32
    at Function.module.exports.Emitter.simpleDispatch (/usr/share/atom/resources/app.asar/node_modules/text-buffer/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/usr/share/atom/resources/app.asar/node_modules/text-buffer/node_modules/event-kit/lib/emitter.js:129:28)
    at DisplayLayer.module.exports.DisplayLayer.emitDidChangeSyncEvent (/usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/display-layer.js:366:27)
    at DisplayLayer.module.exports.DisplayLayer.reset (/usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/display-layer.js:227:12)
    at TextEditor.module.exports.TextEditor.resetDisplayLayer (/usr/share/atom/resources/app.asar/src/text-editor.js:368:32)
    at TextEditor.module.exports.TextEditor.subscribeToScopedConfigSettings (/usr/share/atom/resources/app.asar/src/text-editor.js:336:19)
    at /usr/share/atom/resources/app.asar/src/text-editor.js:3:61
    at Function.module.exports.Emitter.simpleDispatch (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
    at TokenizedBuffer.module.exports.TokenizedBuffer.setGrammar (/usr/share/atom/resources/app.asar/src/tokenized-buffer.js:193:27)
    at TextEditor.module.exports.TextEditor.setGrammar (/usr/share/atom/resources/app.asar/src/text-editor.js:2732:35)
    at GrammarListView.module.exports.GrammarListView.confirmed (/usr/share/atom/resources/app.asar/node_modules/grammar-selector/lib/grammar-list-view.js:60:21)
    at GrammarListView.module.exports.SelectListView.confirmSelection (/usr/share/atom/resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21)
    at HTMLLIElement.<anonymous> (/usr/share/atom/resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:139:19)
    at HTMLOListElement.jQuery.event.dispatch (/usr/share/atom/resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
    at HTMLOListElement.elemData.handle (/usr/share/atom/resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)
camel-chased commented 7 years ago

v1.2.27 ?

yyny commented 7 years ago

Yep.

camel-chased commented 7 years ago

ok i will investigate that bug

yyny commented 7 years ago

I reinstalled to make sure, but I did have v1.2.27.

camel-chased commented 7 years ago

ok

yyny commented 7 years ago

Also, I'm not on Mac, but on Ubuntu. Don't think it matters, though.

yyny commented 7 years ago

It seems like a problem with CoffeeScript?

for line in attrs.screenLines

Should never make line undefined.

camel-chased commented 7 years ago

I will let you know in about few hours from now because I'm in work now :)

yyny commented 7 years ago

I have nothing to do, I can take a look, but it does look like the only way for line to become undefined is when attrs.screenLines is modified, or has an undefined in there from the start.

yyny commented 7 years ago

I believe the underlying problem is on line 772. It does indeed look like a problem with CoffeeScript.

tokenizedLines[ actualLines[0]..actualLines[1] ] returns an array with .length 1, But with no actual index 0, e.g.:

var array = [];
array.length = 1;
console.log(array); // `[]`, notice how it doesn't print `[undefined]`.
console.log(array.length); // `1`