Bug 619910 - Misplaced autocomplete suggestions when typing a command in a new line; f=mihai.sucan r=gavin.sharp approval2.0=gavin.sharp

This commit is contained in:
Joe Walker 2010-12-21 09:31:31 +00:00
parent 137495a7a9
commit ae12ad1158
2 changed files with 7 additions and 1 deletions

View File

@ -4505,7 +4505,8 @@ JSTerm.prototype = {
{
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;
},
};

View File

@ -100,6 +100,11 @@ function testCompletion() {
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();
}