             return
         c                     = String.fromCharCode(keyCode)
         complete              = complete.toJS()  # code is ugly without just doing this - doesn't matter for speed
-        code                  = complete.args.code
-        pos                   = complete.args.pos
-        complete.args.code    = code.slice(0, pos) + c + code.slice(pos)
+        code                  = complete.code
+        pos                   = complete.pos
+        complete.code         = code.slice(0, pos) + c + code.slice(pos)
         complete.cursor_end  += 1
-        complete.args.pos    += 1
-        target                = complete.args.code.slice(complete.cursor_start, complete.cursor_end)
+        complete.pos         += 1
+        target                = complete.code.slice(complete.cursor_start, complete.cursor_end)
         complete.matches      = (x for x in complete.matches when misc.startswith(x, target))
         if complete.matches.length == 0
             @clear_complete()
             @set_mode('edit')
         else
-            @set_cell_input(complete.args.id, complete.args.code)
+            @merge_cell_input(complete.id, complete.base, complete.code)
+            complete.base = complete.code
             @setState(complete : immutable.fromJS(complete))
         return
 


    select_complete: (id, item) =>
        complete = @store.get('complete')
        input    = @store.getIn(['cells', id, 'input'])
        @clear_complete()
        @set_mode('edit')
        if complete? and input? and not complete.get('error')?
            new_input = input.slice(0, complete.get('cursor_start')) + item + input.slice(complete.get('cursor_end'))
            # We don't actually make the completion until the next render loop,
            # so that the editor is already in edit mode.  This way the cursor is
            # in the right position after making the change.
            setTimeout((=> @set_cell_input(id, new_input)), 0)

    complete_handle_key: (keyCode) =>
        ###

{IPynbImporter} = require('./import-from-ipynb')

DEFAULT_KERNEL = 'python2'

syncstring    = require('smc-util/syncstring')

###
The actions -- what you can do with a jupyter notebook, and also the
