From 101c74d8b82efb43ade6d67f669d586efc9b943c Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Wed, 2 Dec 2015 09:31:12 -0500
Subject: Changed Command autocomplete to pick a suggestion when space is
 pressed

---
 web/react/stores/suggestion_store.jsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'web/react/stores/suggestion_store.jsx')

diff --git a/web/react/stores/suggestion_store.jsx b/web/react/stores/suggestion_store.jsx
index 5bd13b02d..182f5810f 100644
--- a/web/react/stores/suggestion_store.jsx
+++ b/web/react/stores/suggestion_store.jsx
@@ -38,6 +38,7 @@ class SuggestionStore extends EventEmitter {
         // items: a list of objects backing the terms which may be used in rendering
         // components: a list of react components that can be used to render their corresponding item
         // selection: the term currently selected by the keyboard
+        // completeOnSpace: whether or not space will trigger the term to be autocompleted
         this.suggestions = new Map();
     }
 
@@ -78,7 +79,8 @@ class SuggestionStore extends EventEmitter {
             terms: [],
             items: [],
             components: [],
-            selection: ''
+            selection: '',
+            completeOnSpace: true
         });
     }
 
@@ -93,6 +95,7 @@ class SuggestionStore extends EventEmitter {
         suggestion.terms = [];
         suggestion.items = [];
         suggestion.components = [];
+        suggestion.completeOnSpace = true;
     }
 
     clearSelection(id) {
@@ -117,6 +120,12 @@ class SuggestionStore extends EventEmitter {
         suggestion.matchedPretext = matchedPretext;
     }
 
+    setCompleteOnSpace(id, completeOnSpace) {
+        const suggestion = this.suggestions.get(id);
+
+        suggestion.completeOnSpace = completeOnSpace;
+    }
+
     addSuggestion(id, term, item, component) {
         const suggestion = this.suggestions.get(id);
 
@@ -180,6 +189,10 @@ class SuggestionStore extends EventEmitter {
         return this.suggestions.get(id).selection;
     }
 
+    shouldCompleteOnSpace(id) {
+        return this.suggestions.get(id).completeOnSpace;
+    }
+
     selectNext(id) {
         this.setSelectionByDelta(id, 1);
     }
-- 
cgit v1.2.3-1-g7c22

