                 else if event.type is 'keyup' and event.altKey and event.which is 38 # Key up
                     if @history_displayed_id < @history.length
                         @history_displayed_id++
-                        @codemirror.setValue @history[@history.length-@history_displayed_id]
+                        @codemirror.setValue @history[@history.length-@history_displayed_id].query
                         event.preventDefault()
                         return true
                 else if event.type is 'keyup' and event.altKey and event.which is 40 # Key down
                     if @history_displayed_id > 1
                         @history_displayed_id--
-                        @codemirror.setValue @history[@history.length-@history_displayed_id]
+                        @codemirror.setValue @history[@history.length-@history_displayed_id].query
                         event.preventDefault()
                         return true
                     else if @history_displayed_id is 1

                @history_displayed_id = 0
                @draft = @codemirror.getValue()

            if event?.which isnt 9 # has to be before create_suggestion()
                @cursor_for_auto_completion = @codemirror.getCursor()

            # We just look at key up so we don't fire the call 3 times
            if event?.type? and event.type isnt 'keyup' and event.which isnt 9 and event.type isnt 'mouseup'

                query: query_before_cursor
                result: result

            if result.suggestions?.length > 0
                for suggestion, i in result.suggestions
                    @current_suggestions.push suggestion
