 
             # Save the last query (even incomplete)
             @state.current_query = @codemirror.getValue()
+            @save_current_query()
 
             # Look for special commands
             if event?.which?

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

        delete_query: (event) =>
            that = @

            # 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
