     ]
     idx++
   posArray
+
 setCursors = (editor, posArray) ->
   idx = 0
-
-  while idx < posArray.length
+  len = posArray.length
+  # console.log "setCursors: #{posArray}"
+  while idx < len
+    # console.log idx
     bufferPosition = posArray[idx]
+    idx++
+    # console.log bufferPosition
     if idx is 0
       editor.setCursorBufferPosition bufferPosition
       continue
     editor.addCursorAtBufferPosition bufferPosition
-    idx++
   return
+
 verifyExists = (fullPath) ->
   (if fs.existsSync(fullPath) then fullPath else null)
 


  # Asynchronously and callback-style
  beautifyCompleted = (text) ->
    if oldText isnt text
      posArray = getCursors(editor)
      origScrollTop = editor.getScrollTop()
      if isSelection
        editor.setTextInBufferRange editor.getSelectedBufferRange(), text
      else
        editor.setText text
      setCursors editor, posArray

      # Let the scrollTop setting run after all the save related stuff is run,
      # otherwise setScrollTop is not working, probably because the cursor
      # addition happens asynchronously
      setTimeout (->
        editor.setScrollTop origScrollTop
        return
      ), 0
    return
  text = undefined
  editor = atom.workspace.getActiveEditor()
  isSelection = !!editor.getSelectedText()

  envs = getUserHome()
  home = path.normalize(path.join(envs, config))
  proj = findFile(config, dir)
  return proj if proj
  return home if verifyExists(home)
  null
getConfigOptionsFromSettings = (langs) ->
  config = atom.config.getSettings()["atom-beautify"]
