               socketStart = @tree.getTokenAtLocation operation.location
               socketStart.socket.content().remove()
               socketStart.insert new model.TextToken operation.before
-
-              moveCursorTo socketStart
+              
+              setTextInputFocus socketStart.socket
+              textInputSelectAll()
+
             when 'socketReparse'
               socketStart = @tree.getTokenAtLocation operation.location
               socketStart.append socketStart.socket.end

        # Focus the hidden input
        setTimeout (=> @hiddenInput.focus()), 0

      setTextInputHead = (point) =>
        textInputHead = Math.round (point.x - @focus.view.bounds[_editedInputLine].x) / @mainCtx.measureText(' ').width


      ctrlKeyPressed = false

      @el.addEventListener 'keydown', (event) =>
        # Keyboard shortcuts don't apply if they were executed in a text input area (except for UNDO)
        if event.target.tagName in ['INPUT', 'TEXTAREA'] and not (event.keyCode in [17, 90]) then return
        
        switch event.keyCode
          when 13 then unless @isEditingText() then insertHandwrittenBlock()
