From ef00d22cf26fb6b3eed143b0f072c2786f90267c Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Sun, 16 Feb 2014 00:15:06 +0000 Subject: [PATCH 1/2] Bug 973153 - disable (undo) reset buttons at the start of Australis' customize mode transitions to prevent breakage, r=Unfocused --- .../components/customizableui/src/CustomizeMode.jsm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/browser/components/customizableui/src/CustomizeMode.jsm b/browser/components/customizableui/src/CustomizeMode.jsm index af8ed78117d..ff13ac89bce 100644 --- a/browser/components/customizableui/src/CustomizeMode.jsm +++ b/browser/components/customizableui/src/CustomizeMode.jsm @@ -136,6 +136,11 @@ CustomizeMode.prototype = { this._handler.isEnteringCustomizeMode = true; + // Always disable the reset button at the start of customize mode, it'll be re-enabled + // if necessary when we finish entering: + let resetButton = this.document.getElementById("customization-reset-button"); + resetButton.setAttribute("disabled", "true"); + Task.spawn(function() { // We shouldn't start customize mode until after browser-delayed-startup has finished: if (!this.window.gBrowserInit.delayedStartupFinished) { @@ -313,6 +318,11 @@ CustomizeMode.prototype = { let panelContents = window.PanelUI.contents; panelContents.setAttribute("customize-transitioning", "true"); + // Disable the reset and undo reset buttons while transitioning: + let resetButton = this.document.getElementById("customization-reset-button"); + let undoResetButton = this.document.getElementById("customization-undo-reset-button"); + undoResetButton.hidden = resetButton.disabled = true; + this._transitioning = true; Task.spawn(function() { From a58a6ffb257e814f2d34a8756205aa2219fe75e3 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Sun, 16 Feb 2014 13:56:26 +0530 Subject: [PATCH 2/2] Bug 971276 - Hitting enter should insert the currently selected item from an autocomplete list in the Style Editor, r=harth --- browser/devtools/sourceeditor/autocomplete.js | 50 ++++++++----------- .../test/browser_styleeditor_autocomplete.js | 9 +++- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/browser/devtools/sourceeditor/autocomplete.js b/browser/devtools/sourceeditor/autocomplete.js index 42a6708d437..71ea5da53f9 100644 --- a/browser/devtools/sourceeditor/autocomplete.js +++ b/browser/devtools/sourceeditor/autocomplete.js @@ -28,39 +28,34 @@ function setupAutoCompletion(ctx, walker) { autoSelect: true }); + let cycle = (reverse) => { + if (popup && popup.isOpen) { + cycleSuggestions(ed, reverse == true); + return; + } + + return win.CodeMirror.Pass; + }; + let keyMap = { - "Tab": cm => { + "Tab": cycle, + "Down": cycle, + "Shift-Tab": cycle.bind(this, true), + "Up": cycle.bind(this, true), + "Enter": () => { if (popup && popup.isOpen) { - cycleSuggestions(ed); + 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(); return; } return win.CodeMirror.Pass; - }, - "Shift-Tab": cm => { - if (popup && popup.isOpen) { - 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); @@ -172,7 +167,6 @@ function onEditorKeypress(ed, event) { case event.DOM_VK_END: case event.DOM_VK_BACK_SPACE: case event.DOM_VK_DELETE: - case event.DOM_VK_RETURN: private.doNotAutocomplete = true; private.popup.hidePopup(); break; diff --git a/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js b/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js index 48780db02f7..af32e20958c 100644 --- a/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js +++ b/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js @@ -49,7 +49,7 @@ let TEST_CASES = [ ['VK_RETURN', -1], ['b', 2, 0], ['u', 1, 0], - ['VK_TAB', -1], + ['VK_RETURN', -1, 0, 1], ['{', -1], ['VK_HOME', -1], ['VK_DOWN', -1], @@ -147,6 +147,13 @@ function checkState() { } 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();