     else
       CodeMirror.Pass
   'Shift-Up': (cm) ->
-    previous_context = context_at_offset cm.lead_cell, -1
+    previous_context = input_cell_at_offset cm.lead_cell, -1
     if previous_context?
       cm.setValue previous_context.editor.getValue()
       cm.setCursor(line: cm.lineCount() - 1)

  contexts.splice index, 1

add_context = (code='') ->
  cell = get_available_context()
  if cell?
    cell.editor.setValue code
  else

  Down: (cm) ->
    cur = cm.getCursor()
    if cur.line is cm.lineCount() - 1
      next_context = input_cell_at_offset cm.lead_cell, 1
      if next_context?
        next_context.editor.focus()
      else
