           bufStart = selection.getBufferRange().serialize()[0]
           jsxformat.setOptions({});
           result = jsxformat.format(selection.getText())
-          selection.insertText(result, {autoIndent: true});
+          selection.insertText(result, autoIndent: true);
           editor.setCursorBufferPosition(bufStart)
         catch err
           # Parsing/formatting the selection failed lets try to parse the whole file but format the selection only

path   = require 'path'
{Subscriber} = require 'emissary'

# use same docblock parser as jsxtransformer does
isJSX = (text) ->
  docblock = require 'jstransform/src/docblock'
  doc = docblock.parse text;
  for b in doc
    return true if b[0] == 'jsx'
  false

class AtomReact
  Subscriber.includeInto(this)

    @patchEditorLangModeSuggestedIndentForBufferRow(editor)
    @patchEditorLangModeAutoDecreaseIndentForBufferRow(editor)

  isJSX: (text) ->
    docblock = require 'jstransform/src/docblock'
    doc = docblock.parse text;
    for b in doc
      return true if b[0] == 'jsx'
    false

  autoSetGrammar: (editor) ->
    return if editor.getGrammar().scopeName == "source.js.jsx"

    path = require 'path'

    # Check if file extension is .jsx or the file has the old JSX notation
    extName = path.extname(editor.getPath())
    if extName is ".jsx" or (extName is ".js" and @isJSX(editor.getText()))
      jsxGrammar = atom.syntax.grammarsByScopeName["source.js.jsx"]
      editor.setGrammar jsxGrammar if jsxGrammar

  onHTMLToJSX: ->
    jsxformat = require 'jsxformat'
    HTMLtoJSX = require './lib/htmltojsx'
    converter = new HTMLtoJSX(createClass: false)

    editor = atom.workspace.getActiveEditor()

    return if not editor?

    selections = editor.getSelections()

    editor.transact =>
