             x = cm.getLine(line)
             if x.length > 0 and x[0] == MARKERS.cell
                 cm.setCursor(line:line+1, ch:0)
-                return
+                return line-1
             line += 1
         # there is no next cell, so we create one at the last non-whitespace line
         while line > 0 and $.trim(cm.getLine(line)).length == 0
             line -= 1
         @cell_start_marker(line+1)
         cm.setCursor(line:line+2, ch:0)
+        return line
 
     ##########################################
     # Codemirror-based cell manipulation code

        @cell_start_marker(pos.line)
        @sync()

    move_cursor_to_next_cell: () =>
        cm = @codemirror
        line = cm.getCursor().line + 1

             worksheet = new Worksheet(@)

             code = mesg.javascript.code
             console.log("evaluating javascript: '#{code}'")
             if mesg.javascript.coffeescript
                 code = CoffeeScript.compile(code)
             if mesg.obj?
                 obj  = JSON.parse(mesg.obj)

             #console.log("executing script: '#{code}', obj='#{mesg.obj}'")

