blakeembrey / atom-dash

Dash documentation integration with Atom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read property 'start' of undefined

roustem opened this issue · comments

[Enter steps to reproduce below:]

  1. Press Ctrl-H when cursor is under a word.

Atom Version: 0.209.0
System: Mac OS X 10.10.3
Thrown From: dash package, v1.2.0

Stack Trace

Uncaught TypeError: Cannot read property 'start' of undefined

At /Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/range.js:35

TypeError: Cannot read property 'start' of undefined
  at Function.module.exports.Range.fromObject (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/range.js:35:31)
  at TextBuffer.module.exports.TextBuffer.getTextInRange (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:373:36)
  at TextEditor.module.exports.TextEditor.getTextInBufferRange (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:619:26)
  at atom-text-editor.module.exports.shortcut (/Users/roustem/.atom/packages/dash/lib/dash.coffee:41:21)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:238:29)
  at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:520:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:355:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:177:20)

Commands

     -0:49.6.0 editor:newline (atom-text-editor.editor.is-focused)
  2x -0:49.2.0 core:save (atom-text-editor.editor.is-focused)
  2x -0:21.3.0 core:select-up (atom-text-editor.editor.is-focused)
     -0:20.8.0 editor:toggle-line-comments (atom-text-editor.editor.is-focused)
     -0:20.5.0 core:save (atom-text-editor.editor.is-focused)
     -0:10.4.0 dash:shortcut (atom-text-editor.editor.is-focused)
     -0:06.8.0 core:move-left (atom-text-editor.editor.is-focused)
     -0:06.4.0 editor:move-to-beginning-of-word (atom-text-editor.editor.is-focused)
     -0:05.4.0 editor:delete-to-beginning-of-word (atom-text-editor.editor.is-focused)
     -0:04.7.0 core:undo (atom-text-editor.editor.is-focused)
     -0:03.4.0 dash:shortcut (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:02.5.0 autocomplete-plus:cancel (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:02.1.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:02.1.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:01.3.0 core:move-right (atom-text-editor.editor.is-focused)
     -0:00.6.0 dash:shortcut (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "projectHome": "/Users/roustem/Projects",
    "themes": [
      "one-light-ui",
      "one-light-syntax"
    ]
  }
}

Installed Packages

# User
.bin, vundefined
atom-typescript, v4.5.13
dash, v1.2.0
go-plus, v3.3.11
linter, v0.12.7

# Dev
No dev packages

Hi @roustem. I verified that it is indeed possible to get an undefined range so I've released a patch for that. It will fallback to the current word under your cursor. If you're having an issue after the patch though (unexpected word lookup maybe?), please post a code snippet I can replicate the issue. Thanks for the report! 👍

Thank you for the patch, @blakeembrey! It fixed the problem for me.

I'm still seeing this error in some consistently reproducible cases, usually when the cursor is at the beginning of words. Here are two simple cases, in Go and Python:

func init() {
    log.SetFlags(log.LstdFlags | log.Lshortfile)
}
if True:
    print "Hello"

With the cursor in front of the "S" in SetFlags or the "p" in print, I'm getting the error when I invoke Ctrl-h.

If this isn't enough to reproduce, please let me know and I'll dump full report details from Atom.

@ches Thanks for the test case! This was definitely a regression from a recent patch (#26), but I've added your test case now to ensure it doesn't get hit again. Thanks 👍

Edit: Oh, and I've released it with 1.3.2 😄

Awesome, thank you for the quick fix @blakeembrey!