         head = head.prev
 
       if head?
-        if @textFocus? and head.container.hasParent @textFocus.parent
-          persistentParent = @textFocus.getCommonParent(head.container).parent
-
-          chars = getCharactersTo persistentParent, head.container.start
+        # Avoid problems with reparses by getting text offset location
+        # of the given socket before reparsing and recovering it afterward.
+        if @textFocus?
+          chars = @getCharactersTo head.container.start
           @setTextInputFocus null
-          socket = getSocketAtChar persistentParent, chars
+          socket = @getSocketAtChar chars
         else
           socket = head.container
           @setTextInputFocus null

        # Now that we've done that, we can annul stuff.
        @endDrag()

  Editor::reparseRawReplace = (oldBlock) ->
    try
      newParse = @mode.parse(oldBlock.stringify(@mode), wrapAtRoot: true)
      newBlock = newParse.start.next.container


    @redrawHighlights()

  Editor::markBlock = (block, style) ->
    key = @nextMarkedBlockId++

    @markedBlocks[key] = {
      model: block
      style: style
    }

    return key

  # ## Mark
  # `mark(line, col, style)` will mark the first block after the given (line, col) coordinate
  # with the given style.
