     set_code: add_context
     run: run_in_available_context
     clear_output: -> clear_contexts()
-    previously_run: -> context_at_offset(input_cell, -1).editor.getValue()
+    previously_run: -> input_cell_at_offset(input_cell, -1).editor.getValue()
     hide_input: -> remove_cell input_cell
     value: (value) -> _lead_cli_value: value
     async: (fn) ->

  $document.empty()
  contexts = []

context_at_offset = (context, offset) ->
  index = contexts.indexOf context
  contexts[index + offset]

get_available_context = ->
  last = contexts[contexts.length - 1]
  if last?.is_clean()
    return last

    else
      CodeMirror.Pass
  'Shift-Up': (cm) ->
    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)
