             (buffer-substring-no-properties beg end))
            (setq-local
             emdocs-undo-list
-            (cons (list :type "insert" :point beg :end end
+            ;; :start and :end are offsets from the original string
+            (cons (list :type "insert" :point beg :start 0 :end 0
                         :content (buffer-substring-no-properties beg end)
                         :local (not emdocs-is-network-insert))
                   emdocs-undo-list)))

           (emdocs-emit-keypress-json
            (buffer-name) "delete" beg prev-length))))
  (unless emdocs-is-network-insert
    (setq-local emdocs-undo-posn emdocs-undo-list)))

(defun emdocs-before-change-function (beg end)
  "docstring"

             (/= beg end))
    (setq-local
     emdocs-undo-list
     (cons (list :type "delete" :point beg
                 :content (buffer-substring-no-properties beg end)
                 :local (not emdocs-is-network-insert))
           emdocs-undo-list))))
