 
     insert_new_cell: (line) =>
         pos = {line:line, ch:0}
-        @codemirror.replaceRange('\n', pos)
-        @codemirror.focus()
-        @codemirror.setCursor(pos)
+        @focused_codemirror().replaceRange('\n', pos)
+        @focused_codemirror().focus()
+        @focused_codemirror().setCursor(pos)
         @cell_start_marker(line)
         @process_sage_updates()
         @sync()
 
     cell_start_marker: (line) =>
-        cm = @codemirror
+        cm = @focused_codemirror()
         x = cm.findMarksAt(line:line, ch:1)
         if x.length > 0 and x[0].type == MARKERS.cell
             # already properly marked

                    @editor.set_readonly_ui()

                @codemirror.setOption('readOnly', @readonly)
                @editor.codemirror1.setOption('readOnly', @readonly)
                if @_last_sync?
                    # We have sync'd before.
                    synced_before = true


    # returns the line number where the previous cell ends
    move_cursor_to_next_cell: () =>
        cm = @focused_codemirror()
        line = cm.getCursor().line + 1
        while line < cm.lineCount()
            x = cm.getLine(line)
