Bug 619910 - Misplaced autocomplete suggestions when typing a command in a new line; f=mihai.sucan r=gavin.sharp approval2.0=gavin.sharp
authorJoe Walker <jwalker@mozilla.com>
Tue, 21 Dec 2010 09:31:31 +0000
changeset 60007 90a8518157c3bf9619dc307eda3e31acb5c760c9
parent 60006 055216b0ad8b2f29901214d51428e4fe3e81960c
child 60008 4553b507e03a6e07791d36bcf68c439481b38d41
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs619910
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 619910 - Misplaced autocomplete suggestions when typing a command in a new line; f=mihai.sucan r=gavin.sharp approval2.0=gavin.sharp
toolkit/components/console/hudservice/HUDService.jsm
toolkit/components/console/hudservice/tests/browser/browser_webconsole_completion.js
--- a/toolkit/components/console/hudservice/HUDService.jsm
+++ b/toolkit/components/console/hudservice/HUDService.jsm
@@ -4500,17 +4500,18 @@ JSTerm.prototype = {
     this.setInputValue(this.inputNode.value + this.completionValue);
     this.updateCompleteNode("");
   },
 
   updateCompleteNode: function JSTF_updateCompleteNode(suffix)
   {
     this.completionValue = suffix;
 
-    let prefix = new Array(this.inputNode.value.length + 1).join(" ");
+    // completion prefix = input, with non-control chars replaced by spaces
+    let prefix = this.inputNode.value.replace(/[\S]/g, " ");
     this.completeNode.value = prefix + this.completionValue;
   },
 };
 
 /**
  * Generates and attaches the JS Terminal part of the Web Console, which
  * essentially consists of the interactive JavaScript input facility.
  *
--- a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_completion.js
+++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_completion.js
@@ -95,12 +95,17 @@ function testCompletion() {
   jsterm.history.splice(0);   // workaround for bug 592552
 
   input.value = "docu";
   jsterm.complete(jsterm.COMPLETE_HINT_ONLY);
   is(jsterm.completeNode.value, "    ment", "'docu' completion");
   jsterm.execute();
   is(jsterm.completeNode.value, "", "clear completion on execute()");
 
+  // Test multi-line completion works
+  input.value =                 "console.log('one');\nconsol";
+  jsterm.complete(jsterm.COMPLETE_HINT_ONLY);
+  is(jsterm.completeNode.value, "                   \n      e", "multi-line completion");
+
   HUD = jsterm = input = null;
   finishTest();
 }