restoring @ autocomplete
authorNicholas Bollweg <nicholas.bollweg@gtri.gatech.edu>
Fri, 01 Nov 2013 13:28:32 -0400
changeset 2082 d8ce908a3350
parent 2081 4f507e2f7d28
child 2083 4c4a8f67348d
restoring @ autocomplete
playground/jsonld-hint.js
playground/playground.js
--- a/playground/jsonld-hint.js	Fri Nov 01 11:04:25 2013 -0400
+++ b/playground/jsonld-hint.js	Fri Nov 01 13:28:32 2013 -0400
@@ -78,7 +78,8 @@
       start = token.start,
       end = token.end + -1 * (word.slice(-1) === '"'),
       
-      match;
+      match,
+      stripped = false;
       
     function suggest(suggestions){
       return {
@@ -95,9 +96,11 @@
       // i just made an empty list and typed "@"...
       word = "";
       start++;
+      stripped = true;
     }else if(word.match(/^"/)){
       // i just started a quoted string...
       word = word.replace(/(^"|"$)/g, "");
+      stripped = true;
     }
     
     if(isAt){
@@ -105,6 +108,8 @@
       if(!~word.indexOf("@")){
         // and the user is expecting a @
         editor.replaceSelection("@", "end", "+input");
+      }else if(!stripped){
+        start--;
       }
       return suggest(keywordsLike(word.replace("@", "")));
     }else if(match = word.match(/^"[email protected](.*)/)){
--- a/playground/playground.js	Fri Nov 01 11:04:25 2013 -0400
+++ b/playground/playground.js	Fri Nov 01 13:28:32 2013 -0400
@@ -206,7 +206,10 @@
           gutters: ["CodeMirror-lint-markers"],
           theme: "elegant",
           lint: true,
-          extraKeys: {"Ctrl-Space": "autocomplete"},
+          extraKeys: {
+            "Ctrl-Space": "autocomplete",
+            "Shift-2": "at_autocomplete"
+          },
           _playground_key: key
         });