Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Uncaught TypeError: Cannot read property 'length' of undefined #402

Closed

Description

@walles

[Enter steps to reproduce below:]

  1. Double click on a word ('collect_highlights') in a Ruby file
  2. Press cmd-g

Expected result:

  • A search for occurrences of 'collect_highlights'

Current result:

  • An error dialog

Atom Version: 0.204.0
System: Mac OS X 10.10.3
Thrown From: find-and-replace package, v0.169.0

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At /Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:449

TypeError: Cannot read property 'length' of undefined
  at FindView.module.exports.FindView.findAndSelectResult (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:449:23)
  at FindView.findAndSelectResult (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:3:61)
  at FindView.module.exports.FindView.findNext (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:429:19)
  at FindView.findNext (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:3:61)
  at atom-workspace.subscriptions.add.atom.commands.add.find-and-replace:find-next (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/find-and-replace/lib/find-view.js:343:26)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/src/command-registry.js:238:29)
  at /Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:520:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:355:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Users/johan/Downloads/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:178:20)

Commands

     -8:31.1.0 core:move-right (atom-text-editor.editor.is-focused)
     -8:30.5.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:32.5.0 command-palette:toggle (atom-text-editor.editor.is-focused)
  5x -0:31 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:23.7.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:23.7.0 symbols-view:go-to-declaration (atom-text-editor.editor)
     -0:21.7.0 find-and-replace:show (atom-text-editor.editor.is-focused)
  2x -0:18.3.0 find-and-replace:find-next (atom-text-editor.editor.is-focused)
     -0:07.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:07.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:01.0 find-and-replace:find-next (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "themes": [
      "unity-ui",
      "atom-light-syntax"
    ]
  }
}

Installed Packages

# User
autocomplete-paths, v1.0.2
color-picker, v2.0.2
language-gitignore, v0.2.0
linter, v0.12.6
linter-rubocop, v0.2.7
linter-ruby, v0.1.6
minimap, v4.9.0
pigments, v0.3.1
test-status, v0.33.0
unity-ui, v2.0.10

# Dev
No dev packages

Activity

  1. winstliu commented on May 31, 2015

    @winstliu
    Contributor

    Hi @walles, could you please upload the file you were working with as a Gist and then paste the Gist link here? Thanks.

    I just tried reproducing this using a minimal test case:

    collect_highlights
    hi
    collect_highlights

    First, I double-clicked collect_highlights to highlight it. Then, I tried pressing F3 (which is the equivalent of Cmd+G on Windows/Linux), but nothing happened 😦. No error, but that still seems like unexpected behavior to me.

  2. walles commented on May 31, 2015

    @walles
    Author

    Here's the file:
    https://github.com/walles/riff/blob/b9fcd0991e6e4e57116be52ae4b6a2cd1b6e140c/lib/refiner.rb

    Note though that I'm not convinced this is easily reproducible, so a better approach than trying to repro it is stack trace inspired code reading. What can make you try to access length of undefined at find-and-replace/lib/find-view.js:449:23?

  3. shawnbmiller commented on Jul 4, 2015

    @shawnbmiller

    I think I have steps to reproduce this in a slightly different way. This was done on Windows 7, Atom version 1.0.0.

    1. With Atom closed, create a new folder (AtomIssue402).
    2. In the new folder, create a new text file (loremipsum.txt). I added 5 paragraphs of generated lorem ipsum text.
    3. Open Atom.
    4. Click File --> Open Folder. Open folder created in step 1.
    5. In the tree view for directory, click on text file created in step 2.
    6. Click on Find --> Replace in Buffer.
    7. Enter text in "Replace in current buffer" box. I used "sit" (without quotes).
    8. Click Replace button.

    Exception details below:
    Atom Version: 1.0.0
    System: Microsoft Windows 7 Professional
    Thrown From: find-and-replace package, v0.174.0

    Stack Trace

    Uncaught TypeError: Cannot read property 'length' of undefined

    At C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\find-and-replace\lib\find-view.js:480
    
    TypeError: Cannot read property 'length' of undefined
        at FindView.module.exports.FindView.replace (C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\find-and-replace\lib\find-view.js:480:23)
        at FindView.module.exports.FindView.replaceNext (C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\find-and-replace\lib\find-view.js:465:19)
        at HTMLButtonElement.<anonymous> (C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\find-and-replace\lib\find-view.js:3:61)
        at HTMLButtonElement.jQuery.event.dispatch (C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\jquery\dist\jquery.js:4435:9)
        at HTMLButtonElement.elemData.handle (C:\Users\Shawn\AppData\Local\atom\app-1.0.0\resources\app.asar\node_modules\jquery\dist\jquery.js:4121:28)
    

    Commands

         -0:27.6.0 find-and-replace:show-replace (ol.tree-view.full-menu.list-tree.has-collapsable-children.focusable-panel)
      3x -0:20.8.0 core:backspace (atom-text-editor.editor.mini.is-focused)
    

    Config

    {}

    Installed Packages

    # User
    No installed packages
    
    # Dev
    No dev packages
  4. izuzak commented on Jul 5, 2015

    @izuzak
    Contributor

    Thanks for the reproduction steps, @shawnbmiller. ⚡ Using an empty "find" pattern when replacing triggers one such exception (though I'm not sure it's the same problem which was originally reported -- seems to have a different stack trace). /cc @benogle

  5. izuzak commented on Jul 5, 2015

    @izuzak
    Contributor

    Ah, I think that the original problem was fixed by @nathansobo in ed00ffb. We should be able to fix the other report with the same approach -- here's a PR to get us there: #434.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions