From adea42d882a89f5de1fbe2456b6b9b03075718c2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 6 Oct 2011 01:15:17 -0400 Subject: [PATCH] Closes issue #681. --- common/content/commandline.js | 19 ++++++++++++++++--- common/modules/completion.jsm | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index 3f8940bb..8519fa22 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1093,15 +1093,17 @@ var CommandLine = Module("commandline", { .filter(function (c) c.incomplete || c.hasItems && c.items.length), + // TODO: Remove. get completion() { let str = commandline.command; return str.substring(this.prefix.length, str.length - this.suffix.length); }, set completion(completion) { + this._completionItem = null; this.previewClear(); // Change the completion text. - // The second line is a hack to deal with some substring + // The third line is a hack to deal with some substring // preview corner cases. let value = this.prefix + completion + this.suffix; commandline.widgets.active.command.value = value; @@ -1115,6 +1117,16 @@ var CommandLine = Module("commandline", { this._completion = completion; }, + get completionItem() this._completionItem, + set completionItem(tuple) { + let value = this.value; + if (tuple) + value = this.value.substr(0, tuple[0].offset - this.start) + + tuple[0].items[tuple[1]].result; + this.completion = value; + this._completionItem = tuple; + }, + get caret() this.editor.selection.getRangeAt(0).startOffset, set caret(offset) { this.editor.selection.getRangeAt(0).setStart(this.editor.rootElement.firstChild, offset); @@ -1211,6 +1223,7 @@ var CommandLine = Module("commandline", { let cursor = this.selected; if (cursor && cursor[0] == context) { if (cursor[1] >= context.items.length + // FIXME: || this.completion != context.items[cursor[1]].result) { this.selected = null; this.itemList.select(null); @@ -1351,11 +1364,11 @@ var CommandLine = Module("commandline", { if (idx == null || !this.activeContexts.length) { // Wrapped. Start again. this.selected = null; - this.completion = this.value; + this.completionItem = null; } else { this.selected = idx; - this.completion = this.getItem().result; + this.completionItem = idx; } this.itemList.select(idx, null, position); diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 4dea7371..217809cd 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -959,6 +959,7 @@ var Completion = Module("completion", { if (/^about:/.test(context.filter)) context.fork("about", 6, this, function (context) { + context.title = ["about:"]; context.generate = function () { return [[k.substr(services.ABOUT.length), ""] for (k in Cc)