atom / vim-mode

Next generation vim support for atom
MIT License
1.72k stars 253 forks source link

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

Closed tali closed 6 years ago

tali commented 9 years ago

[Enter steps to reproduce below:]

I cannot reproduce it any more. I was playing with vim-mode and markdown-preview and updated to the latest Atom (now 0.179.0) and vim-mode (now 0.31.0). Maybe it was related to some inconsistent state caused by upgrading atom or the vim-mode package.

What I remember:

  1. open markdown file and open markdown-preview
  2. Now I have problems navigating in the text (not reacting to vim movement commands)
  3. Close and reopen the markdown file
  4. Now I could move again, but could not move to the last lines with vim commands
  5. Clicking into the last line, the cursor got moved
  6. Using vim movement commands to move within that line (h,l) triggered the exception

I hope the stack trace still helps to find some bugs :-)

Atom Version: 0.179.0 System: Mac OS X 10.10.2 Thrown From: vim-mode package, v0.31.0

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At /Users/martin/.atom/packages/vim-mode/lib/motions/general-motions.coffee:102

TypeError: Cannot read property 'length' of undefined
  at /Users/martin/.atom/packages/vim-mode/lib/motions/general-motions.coffee:102:15
  at Object._.times (/Users/martin/.atom/packages/vim-mode/node_modules/underscore-plus/node_modules/underscore/underscore.js:1119:53)
  at MoveRight.execute (/Users/martin/.atom/packages/vim-mode/lib/motions/general-motions.coffee:103:5)
  at VimState.module.exports.VimState.processOpStack (/Users/martin/.atom/packages/vim-mode/lib/vim-state.coffee:148:15)
  at VimState.module.exports.VimState.pushOperations (/Users/martin/.atom/packages/vim-mode/lib/vim-state.coffee:141:35)
  at atom-text-editor.commands.(anonymous function) (/Users/martin/.atom/packages/vim-mode/lib/vim-state.coffee:136:34)
  at atom-text-editor.handler (/Applications/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:115:32)
  at atom-text-editor.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4681:9)
  at atom-text-editor.elemData.handle (/Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4359:46)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243:29)
  at /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:558:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:396:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:172:20)

Commands

 14x -0:15.7 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
     -0:09.5 vim-mode:move-up (atom-text-editor.editor.vim-mode.command-mode.is-focused)
  3x -0:09.1 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
  3x -0:08.3 vim-mode:move-up (atom-text-editor.editor.vim-mode.command-mode.is-focused)
  3x -0:07.6 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
 13x -0:06.9 vim-mode:move-up (atom-text-editor.editor.vim-mode.command-mode.is-focused)
 16x -0:05.2 vim-mode:move-down (atom-text-editor.editor.vim-mode.command-mode.is-focused)
  3x -0:01.3 vim-mode:move-right (atom-text-editor.editor.vim-mode.command-mode.is-focused)

Config

{
  "core": {
    "themes": [
      "atom-light-ui",
      "atom-light-syntax"
    ],
    "disabledPackages": [
      "metrics"
    ]
  },
  "vim-mode": {}
}

Installed Packages

# User
linter, v0.11.1
minimap, v4.1.4
vim-mode, v0.31.0

# Dev
No dev packages
nassredean commented 9 years ago

Hello. I am able to reproduce this error in the following way.

Open a new file. add a new line. add a new line. add a closing bracket or paren ) } move key cursor to bracket/paren. enter normal mode. hit parentheses (bracket matcher). Error occurs.

Seems this error occurs only when there is an unmatched closing bracket and a new line at the beginning of the file.

I have forked the repo and added a fix. Open for review here: https://github.com/atom/vim-mode/pull/848

lee-dohm commented 6 years ago

As stated in the README, this package is no longer maintained and is deprecated. We recommend that people use the vim-mode-plus package instead. Because of this, we are archiving this repository and closing all issues and pull requests. Thanks very much for your support and contributions!