       throw new Error "Index out of bounds"
     @_rte.words[index].word = content
 
-  # Split the content around ' ' and append all the words created to the object
-  #
-  _push: (content) ->
-    for w in content.split(' ')
-      @_rte.words.push(w)
+  # Append new words at the end of the word list
+  # @param [String] content the string to append
+  push: (content) ->
+    console.log '"' + content + '"'
+    preSpaces = content.match PreSpacesRegExp
+    if preSpaces isnt null
+      @_rte.words.push(new Word (preSpaces[0]))
+    words = content.match WordRegExp
+    console.log '"' + preSpaces + '"'
+    console.log words
+    if _.isArray(words)
+      for w in words
+        @_rte.words.push (new Word w)
 
   # Insert words at position
   #

    index = sel.startPos.word   #position to work from
    pos = sel.startPos.pos

    wordsToInsert = content.match /\w+ +/g
    preSpaces = content.search /^ +/

    currWord = @getWord index


_ = require 'underscore'
# XRegExp = require('xregexp').XRegExp
WordRegExp = /\S+\s*/g
PreSpacesRegExp = /^\s+/
# Simple class that contains a word and links to the selections pointing
# to it
class Word
