Backed out changeset 2ac2e3a81f7b (bug 971276)
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 18 Feb 2014 12:56:25 -0500
changeset 182895 1e578a03b49173071b79661207e29ca29a6f2fa8
parent 182894 fbabfaa4ab777a473ab0b2cf6fd385ea2749e173
child 182896 c6c359ce5f0287737c0031239640c707fa736742
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs971276
milestone29.0a2
backs out2ac2e3a81f7b940cb16367376497d6692e2d4c9b
Backed out changeset 2ac2e3a81f7b (bug 971276)
browser/devtools/sourceeditor/autocomplete.js
browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js
--- a/browser/devtools/sourceeditor/autocomplete.js
+++ b/browser/devtools/sourceeditor/autocomplete.js
@@ -23,44 +23,49 @@ function setupAutoCompletion(ctx, walker
 
   let popup = new AutocompletePopup(win.parent.document, {
     position: "after_start",
     fixedWidth: true,
     theme: "auto",
     autoSelect: true
   });
 
-  let cycle = (reverse) => {
-    if (popup && popup.isOpen) {
-      cycleSuggestions(ed, reverse == true);
-      return;
-    }
-
-    return win.CodeMirror.Pass;
-  };
+  let keyMap = {
+    "Tab": cm => {
+      if (popup && popup.isOpen) {
+        cycleSuggestions(ed);
+        return;
+      }
 
-  let keyMap = {
-    "Tab": cycle,
-    "Down": cycle,
-    "Shift-Tab": cycle.bind(this, true),
-    "Up": cycle.bind(this, true),
-    "Enter": () => {
+      return win.CodeMirror.Pass;
+    },
+    "Shift-Tab": cm => {
       if (popup && popup.isOpen) {
-        if (!privates.get(ed).suggestionInsertedOnce) {
-          privates.get(ed).insertingSuggestion = true;
-          let {label, preLabel} = popup.getItemAtIndex(0);
-          let cur = ed.getCursor();
-          ed.replaceText(label.slice(preLabel.length), cur, cur);
-        }
-        popup.hidePopup();
+        cycleSuggestions(ed, true);
         return;
       }
 
       return win.CodeMirror.Pass;
-    }
+    },
+    "Up": cm => {
+      if (popup && popup.isOpen) {
+        cycleSuggestions(ed, true);
+        return;
+      }
+
+      return win.CodeMirror.Pass;
+    },
+    "Down": cm => {
+      if (popup && popup.isOpen) {
+        cycleSuggestions(ed);
+        return;
+      }
+
+      return win.CodeMirror.Pass;
+    },
   };
   keyMap[Editor.accel("Space")] = cm => autoComplete(ctx);
   cm.addKeyMap(keyMap);
 
   cm.on("keydown", (cm, e) => onEditorKeypress(ed, e));
   ed.on("change", () => autoComplete(ctx));
   ed.on("destroy", () => {
     cm.off("keydown", (cm, e) => onEditorKeypress(ed, e));
@@ -163,16 +168,17 @@ function onEditorKeypress(ed, event) {
         event.preventDefault();
     case event.DOM_VK_LEFT:
     case event.DOM_VK_RIGHT:
     case event.DOM_VK_HOME:
     case event.DOM_VK_END:
     case event.DOM_VK_BACK_SPACE:
     case event.DOM_VK_DELETE:
     case event.DOM_VK_ENTER:
+    case event.DOM_VK_RETURN:
       private.doNotAutocomplete = true;
       private.popup.hidePopup();
       break;
 
     default:
       private.doNotAutocomplete = false;
   }
 }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js
@@ -44,17 +44,17 @@ let TEST_CASES = [
   ['VK_TAB', 4, 1, 1],
   ['VK_TAB', 4, 2, 1],
   ['VK_LEFT', -1],
   ['VK_RIGHT', -1],
   ['VK_DOWN', -1],
   ['VK_RETURN', -1],
   ['b', 2, 0],
   ['u', 1, 0],
-  ['VK_RETURN', -1, 0, 1],
+  ['VK_TAB', -1],
   ['{', -1],
   ['VK_HOME', -1],
   ['VK_DOWN', -1],
   ['VK_DOWN', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
@@ -142,23 +142,16 @@ function checkState() {
         let { line, ch } = gEditor.getCursor();
         let lineText = gEditor.getText(line);
         is(lineText.substring(ch - label.length, ch), label,
            "Current suggestion from the popup is inserted into the editor.");
       }
     }
     else {
       ok(!gPopup.isOpen, "Popup is closed for index " + index);
-      if (inserted) {
-        let { preLabel, label } = gPopup.getItemAtIndex(current);
-        let { line, ch } = gEditor.getCursor();
-        let lineText = gEditor.getText(line);
-        is(lineText.substring(ch - label.length, ch), label,
-           "Current suggestion from the popup is inserted into the editor.");
-      }
     }
     index++;
     testState();
   });
 }
 
 function testAutocompletionDisabled() {
   gBrowser.removeCurrentTab();