t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Uncaught Error from Sort #1084

Closed jchristianhall closed 6 years ago

jchristianhall commented 6 years ago

Description

After updating to the latest vim-mode-plus, the sort function is throwing an uncaught error. I have the following in my keymap.cson:

'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  'g s': 'vim-mode-plus:sort'

I have not noticed this problem with any other vim keystrokes

Steps to reproduce

  1. Select lines with shift + V
  2. Sort with g s

Atom: 1.28.0 x64 Electron: 2.0.3 OS: Mac OS X 10.13.5 Thrown From: vim-mode-plus package 1.33.0

Stack Trace

Uncaught TypeError: null is not a function!

At /Users/christianhall/.atom/packages/vim-mode-plus/lib/operation-stack.js:164

TypeError: null is not a function!
    at module.exports (/packages/git-plus/node_modules/core-js/modules/_a-function.js:2:38)
    at Array.sort (/packages/git-plus/node_modules/core-js/modules/es6.array.sort.js:21:36)
    at Object.changeArrayOrder (/packages/vim-mode-plus/lib/utils.js:1250:28)
    at Sort.getNewList (/packages/vim-mode-plus/lib/operator-transform-string.js:744:25)
    at /packages/vim-mode-plus/lib/operator-transform-string.js:737:55
    at Sort.sortArgumentsInTextBy (/packages/vim-mode-plus/lib/operator-transform-string.js:755:21)
    at Sort.getNewText (/packages/vim-mode-plus/lib/operator-transform-string.js:737:14)
    at Sort.mutateSelection (/packages/vim-mode-plus/lib/operator-transform-string.js:25:23)
    at Sort.mutateSelections (/packages/vim-mode-plus/lib/operator.js:258:12)
    at Sort.execute (/packages/vim-mode-plus/lib/operator.js:286:35)
    at OperationStack.execute (/packages/vim-mode-plus/lib/operation-stack.js:200:33)
    at OperationStack.process (/packages/vim-mode-plus/lib/operation-stack.js:193:12)
    at OperationStack.run (/packages/vim-mode-plus/lib/operation-stack.js:105:14)
    at /packages/vim-mode-plus/lib/vim-state.js:70:33)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49)
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:621:22)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:412:28)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/src/window-event-handler.js:110:40)

Commands

     -1:48.8.0 key-binding-resolver:toggle (input.hidden-input)
     -1:45.4.0 vim-mode-plus:activate-normal-mode (input.hidden-input)
  2x -1:42.3.0 vim-mode-plus:sort (input.hidden-input)
     -1:16.3.0 find-and-replace:show (input.hidden-input)
     -1:13.2.0 core:confirm (input.hidden-input)
     -1:10.9.0 key-binding-resolver:toggle (input.hidden-input)
     -1:09.2.0 editor:consolidate-selections (input.hidden-input)
     -1:09.2.0 core:cancel (input.hidden-input)
     -0:28.3.0 vim-mode-plus:insert-after (input.hidden-input)
     -0:24.8.0 core:undo (input.hidden-input)
     -0:22 vim-mode-plus:activate-normal-mode (input.hidden-input)
     -0:21.8.0 vim-mode-plus:move-up (input.hidden-input)
     -0:21.4.0 vim-mode-plus:move-down (input.hidden-input)
     -0:21.1.0 vim-mode-plus:activate-linewise-visual-mode (input.hidden-input)
 15x -0:21 vim-mode-plus:move-up (input.hidden-input)
  2x -0:18.9.0 vim-mode-plus:sort (input.hidden-input)

Non-Core Packages

atom-alignment 0.13.0 
atom-ide-ui 0.12.0 
atom-snazzy-clear-syntax 0.5.5 
atom-snazzy-syntax 0.2.0 
atom-snazzy-ui 1.1.1 
atom-wrap-in-tag 0.6.0 
base16-ocean-dark-spacegray 0.13.0 
base16-syntax 1.8.1 
busy-signal 1.4.3 
file-icons 2.1.21 
gist-it 0.9.2 
git-plus 7.12.0 
highlight-selected 0.13.1 
intentions 1.1.5 
language-diff 0.7.0 
language-liquid 0.7.0 
language-postcss 1.3.1 
linter 2.2.0 
linter-coffeelint 2.0.0 
linter-eslint 8.4.1 
linter-rubocop 2.2.3 
linter-stylelint 4.3.2 
linter-ui-default 1.7.1 
move-panes 0.2.0 
nerd-treeview 0.5.4 
one-dark-vivid-syntax 1.8.1 
prettier-atom 0.54.0 
react 0.18.0 
seti-syntax 1.1.3 
seti-ui 1.10.0 
sort-lines 0.18.0 
spacegray-dark-ui 0.13.0 
stylefmt 5.0.1 
tab-foldername-index 3.3.0 
tabs-to-spaces 1.0.5 
teletype 0.13.3 
vim-mode-plus 1.33.0 
t9md commented 6 years ago

I cannot reproduce the issue. My OS and Atom version is same as yours.

How about the result when you execute "sort" from command-palette(not via keymap). Btw, you don't need that explicit keymap in your keymap.cson since vmp have already set it by default.

jchristianhall commented 6 years ago

@t9md I get the same error when executing sort from the command palette. I've also removed the explicit keymap from my config. Should I share my vim-mode-plus config as well? I also tried removing the package and reinstalling it, but to no avail.

t9md commented 6 years ago

Yes, you need, do this below. The instruction you removed when you open this issue.

And also, I need exact step and condition to reproduce

t9md commented 6 years ago

Oh, I noticed, who throwing exception is git-plus pkg. Can you still reproduce issue after temporarily disabling git-plus?

t9md commented 6 years ago

The diff between your env and me is this part from your stack trace.

Sort operator call Array.prototype.sort. But in your environment, Array.sort is being called, which seem to be patched by git-plus.

TypeError: null is not a function!
    at module.exports (/packages/git-plus/node_modules/core-js/modules/_a-function.js:2:38)
    at Array.sort (/packages/git-plus/node_modules/core-js/modules/es6.array.sort.js:21:36)
jchristianhall commented 6 years ago

@t9md git-plus was the issue. Sort's working great now. Thanks so much!