Skip to content

Extract for loop as method throws: Uncaught TypeError: Cannot read property 'some' of undefined #458

Description

@niels-numbers

Hi,

I installed the plugin and everything works fine. I also can extract methods.
Except when I try to select a for loop like this:

  for ($i=0; $i < 20; $i++) {
      $this->roll(0);
    }

If I click alt+m and enter a name for the extracted method and hit extract, atom scrolls to the bottom but no new method is inserted. Now for each click in the document the following error message is thrown:

Uncaught TypeError: Cannot read property 'some' of undefined

grafik

/usr/share/atom/resources/app/static/<embedded>:11
Hide Stack Trace
TypeError: Cannot read property 'some' of undefined
    at SnippetExpansion.t.exports.SnippetExpansion.cursorMoved (/usr/share/atom/resources/app/static/<embedded>:11:948501)
    at /usr/share/atom/resources/app/static/<embedded>:11:947907
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at Selection.markerDidChange (/usr/share/atom/resources/app/static/<embedded>:11:543689)
    at Selection.marker.onDidChange.e (/usr/share/atom/resources/app/static/<embedded>:11:528938)
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at DisplayMarker.t.exports.DisplayMarker.notifyObservers (/usr/share/atom/resources/app/static/<embedded>:14:3181496)
    at /usr/share/atom/resources/app/static/<embedded>:14:3176998
    at Function.simpleDispatch (/usr/share/atom/resources/app/static/<embedded>:11:1186173)
    at Emitter.emit (/usr/share/atom/resources/app/static/<embedded>:11:1187614)
    at Marker.t.exports.Marker.emitChangeEvent (/usr/share/atom/resources/app/static/<embedded>:14:67803)
    at Marker.t.exports.Marker.update (/usr/share/atom/resources/app/static/<embedded>:14:66857)
    at Marker.t.exports.Marker.setHeadPosition (/usr/share/atom/resources/app/static/<embedded>:14:63016)
    at DisplayMarker.t.exports.DisplayMarker.setHeadBufferPosition (/usr/share/atom/resources/app/static/<embedded>:14:3178851)
    at DisplayMarker.t.exports.DisplayMarker.setHeadScreenPosition (/usr/share/atom/resources/app/static/<embedded>:14:3179083)
    at changePosition (/usr/share/atom/resources/app/static/<embedded>:11:519079)
    at Cursor.changePosition (/usr/share/atom/resources/app/static/<embedded>:11:527504)
    at Cursor.setScreenPosition (/usr/share/atom/resources/app/static/<embedded>:11:519045)
    at moveCursors.n (/usr/share/atom/resources/app/static/<embedded>:11:30282)
    at Array.forEach (<anonymous>)
    at transact (/usr/share/atom/resources/app/static/<embedded>:11:33144)
    at TextBuffer.transact (/usr/share/atom/resources/app/static/<embedded>:11:489188)
    at TextEditor.transact (/usr/share/atom/resources/app/static/<embedded>:11:24215)
    at TextEditor.moveCursors (/usr/share/atom/resources/app/static/<embedded>:11:33112)
    at TextEditor.setCursorScreenPosition (/usr/share/atom/resources/app/static/<embedded>:11:30265)
    at TextEditorComponent.didMouseDownOnContent (/usr/share/atom/resources/app/static/<embedded>:11:95495)

This is what I tried so far:

  • Tried it on Atom 1.31.2
  • Tried it on latest release Atom 1.32.2
  • Deinstalled the plugin and reinstalled it
  • Restarted my PC and Atom
  • Created a new projekt and initialized a new Serenate projekt
  • Tried it in different files

Every time I could reproduce the issue. I am using Ubuntu 18.04.

Also I noticed, that whenever I extract a method, the method is inserted at the bottom of the file below the class. So I actually always need to copy and paste the method from outsite to inside of my class. Is this intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions