noseglid / autocomplete-java-minus

:coffee: Autocomplete for Java that only autocomplete.
https://atom.io/packages/autocomplete-java-minus
MIT License
9 stars 3 forks source link

Uncaught TypeError: Cannot read property 'id' of null #5

Closed SlimeQ closed 8 years ago

SlimeQ commented 8 years ago

[Enter steps to reproduce below:]

  1. unsure

Atom Version: 1.8.0 System: Ubuntu 14.04.4 Thrown From: autocomplete-java-minus package, v0.12.0

Stack Trace

Uncaught TypeError: Cannot read property 'id' of null

At /home/quincy/.atom/packages/autocomplete-java-minus/lib/editor-tokens.js:70

TypeError: Cannot read property 'id' of null
    at EditorTokens.refreshTokens (/home/quincy/.atom/packages/autocomplete-java-minus/lib/editor-tokens.js:70:39)
    at /home/quincy/.atom/packages/autocomplete-java-minus/lib/editor-tokens.js:78:12
    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/node_modules/text-buffer/lib/text-buffer.js:1378:25

Commands

     -0:20.9.0 core:confirm (atom-text-editor.editor.mini.is-focused)
  2x -0:15.6.0 pane:show-previous-item (ol.results-view.list-tree.focusable-panel.has-collapsable-children)
  2x -0:11.4.0 core:move-down (atom-text-editor.editor.power-mode.is-focused)
     -0:10.6.0 editor:newline (atom-text-editor.editor.power-mode.is-focused)
  2x -0:09.7.0 core:backspace (atom-text-editor.editor.power-mode.is-focused)
     -0:09.1.0 core:move-up (atom-text-editor.editor.power-mode.is-focused)
     -0:08.9.0 editor:newline (atom-text-editor.editor.power-mode.is-focused)
     -0:06.1.0 core:backspace (atom-text-editor.editor.power-mode.is-focused)
     -0:05.1.0 core:save (atom-text-editor.editor.power-mode.is-focused)
     -0:04.2.0 core:move-left (atom-text-editor.editor.power-mode.is-focused)
     -0:03.9.0 java-importer:import (atom-text-editor.editor.power-mode.is-focused)
     -0:03.0 core:move-up (atom-text-editor.editor.power-mode.is-focused)
     -0:02.6.0 core:move-left (atom-text-editor.editor.power-mode.is-focused)
     -0:02.3.0 editor:newline (atom-text-editor.editor.power-mode.is-focused)
     -0:02.0 core:paste (atom-text-editor.editor.power-mode.is-focused)
     -0:01.8.0 core:save (atom-text-editor.editor.power-mode.is-focused)

Config

{
  "core": {
    "ignoredNames": [
      ".git",
      ".hg",
      ".svn",
      ".DS_Store",
      "._*",
      "Thumbs.db",
      "*.class"
    ],
    "themes": [
      "atom-material-ui",
      "atom-material-syntax"
    ]
  }
}

Installed Packages

# User
activate-power-mode, v0.7.0
atom-material-syntax, v0.4.6
atom-material-ui, v1.2.13
autocomplete-java-minus, v0.12.0
busy, v0.5.0
color-tabs, v0.1.8
java-classpath-registry, v0.4.0
java-import-wiz, v0.5.0
java-importer, v1.4.1
language-gradle, v0.0.3
language-groovy, v0.6.0
linter, v1.11.14
linter-javac, v1.9.4
merge-conflicts, v1.4.4

# Dev
No dev packages
jfs commented 8 years ago

This can happen if EditorTokens.refreshTokens is called when no window has focus. Returning null from BrowserWindow.getFocusedWindow is a documented possibility. Would this be an unreasonable fix?

const focusedWindow = remote.BrowserWindow.getFocusedWindow()

if (!focusedWindow) {
    // Oops. No focused window to notify.
    return;
  }
this.worker.webContents.send('tokenize',
  editor.id,
  editor.getText(),
  focusedWindow.id
);
jfs commented 8 years ago

I've personally run into this issue several times now. Any ETA on my pull request?