andersennl / case-switch

Atom editor package to change variable names from kebab- to snake- to camelCase.
MIT License
4 stars 3 forks source link

Toggle case seems to be broken #3

Closed valo closed 8 years ago

valo commented 8 years ago

When I try to use the case toggle I get the error below. It seems the issue that the toggle function is not passing a selection to the functions here: https://github.com/andersennl/case-switch/blob/master/lib/selector.coffee#L8

Atom Version: 1.4.3 System: Mac OS X 10.11.3 Thrown From: case-switch package, v2.0.1

Stack Trace

Uncaught TypeError: Cannot read property 'getText' of undefined

At /Users/valentin/.atom/packages/case-switch/lib/selector.coffee:38

TypeError: Cannot read property 'getText' of undefined
    at Selector.module.exports.Selector.isHyphenCase (/Users/valentin/.atom/packages/case-switch/lib/selector.coffee:38:14)
    at Selector.module.exports.Selector.toggleSelection (/Users/valentin/.atom/packages/case-switch/lib/selector.coffee:9:9)
    at Object.module.exports.CaseSwitch.toggle (/Users/valentin/.atom/packages/case-switch/lib/case-switch.coffee:17:20)
    at atom-workspace.<anonymous> (/Users/valentin/.atom/packages/case-switch/lib/case-switch.coffee:11:67)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260: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:536:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:359:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:97:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -0:07.6.0 core:select-down (atom-text-editor.editor.is-focused)
     -0:07.4.0 core:cut (atom-text-editor.editor.is-focused)
  4x -0:07.3.0 core:move-down (atom-text-editor.editor.is-focused)
     -0:06.7.0 core:paste (atom-text-editor.editor.is-focused)
  2x -0:06.5.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:05.5.0 core:save (atom-text-editor.editor.is-focused)
  2x -0:05.4.0 core:move-down (atom-text-editor.editor.is-focused)
     -0:05.1.0 core:select-down (atom-text-editor.editor.is-focused)
     -0:04.8.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:04.3.0 core:save (atom-text-editor.editor.is-focused)
     -0:04.3.0 pane:show-previous-item (atom-text-editor.editor.is-focused)
  4x -0:03.6.0 core:move-up (atom-text-editor.editor.is-focused)
  2x -0:03.0 editor:move-to-end-of-word (atom-text-editor.editor.is-focused)
     -0:02.6.0 editor:select-to-beginning-of-word (atom-text-editor.editor.is-focused)
  2x -0:02.2.0 editor:select-to-end-of-word (atom-text-editor.editor.is-focused)
     -0:00.9.0 case-switch:toggle (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "ignoredNames": [
      ".git/"
    ],
    "projectHome": "/Users/valentin/workspace"
  }
}

Installed Packages

# User
advanced-open-file, v0.14.2
case-switch, v2.0.1
emmet, v2.3.17
expand-region, v0.2.4
git-plus, v5.12.0
goto, v1.7.1
language-emblem, v0.2.0
language-rspec, v0.3.0
language-slim, v0.5.0
rails-rspec, v0.3.2
rails-transporter, v1.6.5
ruby-block, v0.3.5
ruby-block-converter, v3.5.0

# Dev
No dev packages
valo commented 8 years ago

Added a PR with a fix

andersennl commented 8 years ago

Hi @valo thanks a lot for the heads up and pr, I'll take a look at it asap.