             if num_results >= max_results
                 break
 
-        project_store.getActions(@props.project_id, flux).setTo
-            too_many_results : too_many_results
-            search_results   : search_results
-
-
+        if @state.command is cmd # only update the state if the results are from the most recent command
+            @setState
+                too_many_results : too_many_results
+                search_results   : search_results
+
+
+    set_user_input : (new_value) ->
+        @setState(user_input : new_value)
 
     output_heading : ->
-        if @props.most_recent_search? and @props.most_recent_path?
+        if @state.most_recent_search? and @state.most_recent_path?
             <ProjectSearchOutputHeading
-                most_recent_path   = {@props.most_recent_path}
-                command            = {@props.command}
-                most_recent_search = {@props.most_recent_search}
-                search_results     = {@props.search_results}
-                search_error       = {@props.search_error} />
+                most_recent_path   = {@state.most_recent_path}
+                command            = {@state.command}
+                most_recent_search = {@state.most_recent_search}
+                search_results     = {@state.search_results}
+                search_error       = {@state.search_error} />
 
     output : ->
-        if @props.search_results? or @props.search_error?
-            <ProjectSearchOutput
+        if @state.search_results? or @state.search_error?
+            return <ProjectSearchOutput
                 project_id       = {@props.project_id}
-                results          = {@props.search_results}
-                too_many_results = {@props.too_many_results}
-                search_error     = {@props.search_error} />
-        else if @props.most_recent_search?
+                results          = {@state.search_results}
+                too_many_results = {@state.too_many_results}
+                search_error     = {@state.search_error} />
+        else if @state.most_recent_search?
             # a search has been made but the search_results or search_error hasn't come in yet
             <Loading />
 

ProjectSearchSettings = rclass

    propTypes :
        checkboxes : rtypes.object

    handle_change : (name) ->
        project_store.getActions(@props.project_id, flux).setTo("#{name}": @refs[name].getChecked())

    input : (name, label) ->
        <Input
            ref      = {name}
            key      = {name}
            type     = 'checkbox'
            label    = {label}
            checked  = {@props[name]}
            onChange = {=>@handle_change(name)}
            style    = {fontSize:'16px'} />

    render : ->
        <div style={fontSize:'16px'}>
            {(@input(name, label) for name, label of @props.checkboxes)}
        </div>


ProjectSearchDisplay = rclass

    propTypes: ->
        user_input : rtypes.string
        project_id : rtypes.string

    settings_checkboxes :

        return cmd


    search : ->
        query = @state.user_input
        if query.trim() == ''
            @setState
                search_results     : []
                search_error       : undefined
                command            : ""
                most_recent_search : ""
                most_recent_path   : @props.current_path.join("/")
            return

        cmd = @generate_command(query, @checkbox_state.subdirectories, not @checkbox_state.case_sensitive, @checkbox_state.hidden_files)
        max_results = 1000
        max_output  = 110 * max_results  # just in case

        @setState
            search_results     : undefined
            search_error       : undefined
            command            : cmd
