             # Load options from local storage
             if window.localStorage?.options?
                 @state.options = JSON.parse window.localStorage.options
+
+            # Load the query that was written in code mirror (that may not have been executed before)
+            if typeof window.localStorage?.current_query is 'string'
+                @state.current_query = JSON.parse window.localStorage.current_query
 
             if window.localStorage?.rethinkdb_history?
                 @state.history = JSON.parse window.localStorage.rethinkdb_history

            # Set + save codemirror
            @container.codemirror.setValue @history[parseInt(id)].query
            @container.state.current_query = @history[parseInt(id)].query

        delete_query: (event) =>
            that = @

            @state.history.length = 0
            window.localStorage.rethinkdb_history = JSON.stringify @state.history

        # Save the current query (the one in codemirror) in local storage
        save_current_query: =>
            if window.localStorage?
                window.localStorage.current_query = JSON.stringify @codemirror.getValue()

        initialize: (args) =>
            @TermBaseConstructor = r.expr(1).constructor.__super__.constructor.__super__.constructor

