diff --git a/content/bookmarks.js b/content/bookmarks.js index 5b7a929e..08bca367 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -320,7 +320,11 @@ function Bookmarks() //{{{ }, { bang: true, - completer: function completer(context, args) completion.bookmark(context, args["-tags"]), + completer: function completer(context, args) + { + context.quote = null; + completion.bookmark(context, args["-tags"]); + }, options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]] }); diff --git a/content/completion.js b/content/completion.js index 9b981244..bf09591b 100644 --- a/content/completion.js +++ b/content/completion.js @@ -61,7 +61,7 @@ function CompletionContext(editor, name, offset) self[key] = parent[key]); if (self != this) return self; - ["contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) { + ["_caret", "contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) { self.__defineGetter__(key, function () this.top[key]); self.__defineSetter__(key, function (val) this.top[key] = val); }); @@ -149,7 +149,7 @@ CompletionContext.prototype = { return substrings.reduce(function (a, b) a.length > b.length ? a : b, ""); }, - get caret() (this.editor ? this.editor.selection.getRangeAt(0).startOffset : this.value.length) - this.offset, + get caret() this._caret - this.offset, get compare() this._compare || function () 0, set compare(val) this._compare = val, @@ -176,6 +176,25 @@ CompletionContext.prototype = { get filterFunc() this._filterFunc || util.identity, set filterFunc(val) this._filterFunc = val, + get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret), + set filter(val) + { + delete this._ignoreCase; + return this._filter = val + }, + + get format() ({ + title: this.title, + keys: this.keys, + process: this.process + }), + set format(format) + { + this.title = format.title || this.title; + this.keys = format.keys || this.keys; + this.process = format.process || this.process; + }, + get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this.cache.offset != this.offset), set regenerate(val) { if (val) delete this.itemCache[this.key] }, @@ -197,7 +216,6 @@ CompletionContext.prototype = { let lock = {}; this.cache.backgroundLock = lock; this.incomplete = true; - let now = Date.now(); liberator.callAsync(this, function () { let items = this.generate(); if (this.cache.backgroundLock != lock) @@ -208,25 +226,6 @@ CompletionContext.prototype = { } }, - get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret), - set filter(val) - { - delete this._ignoreCase; - return this._filter = val - }, - - get format() ({ - title: this.title, - keys: this.keys, - process: this.process - }), - set format(format) - { - this.title = format.title || this.title; - this.keys = format.keys || this.keys; - this.process = format.process || this.process; - }, - get ignoreCase() { if ("_ignoreCase" in this) @@ -242,7 +241,7 @@ CompletionContext.prototype = { get items() { - if (!this.hasItems) + if (!this.hasItems || this.backgroundLock) return []; if (this.cache.filtered && this.cache.filter == this.filter) return this.cache.filtered; @@ -437,7 +436,16 @@ CompletionContext.prototype = { this.tabPressed = false; this.title = ["Completions"]; this.updateAsync = false; - this.value = this.editor ? this.editor.rootElement.textContent : this._value; + if (this.editor) + { + this.value = this.editor.rootElement.textContent; + this._caret = this.editor.selection.getRangeAt(0).startOffset; + } + else + { + this.value = this._value; + this._caret = this.value.length; + } //for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret))) // delete this.contexts[key]; for each (let context in this.contexts) @@ -1001,9 +1009,6 @@ function Completion() //{{{ return []; var hasTags = urls[0].tags !== undefined; - // TODO: create a copy of urls? - if (!filter && (!hasTags || !filterTags)) - return urls; filterTags = filterTags || []; diff --git a/content/ui.js b/content/ui.js index 47c75482..8260625b 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1231,6 +1231,7 @@ function CommandLine() //{{{ catch (e) {} doc.body.style.minWidth = commandlineWidget.scrollWidth + "px"; outputContainer.height = Math.min(doc.height, availableHeight) + "px"; + doc.body.style.minWidth = undefined; outputContainer.collapsed = false; }, @@ -1321,7 +1322,7 @@ function ItemList(id) //{{{ doc.body.id = id + "-content"; doc.body.appendChild(doc.createTextNode("")); - doc.body.style.borderTop = "1px solid black"; // FIXME: For cases where completions/MOW are shown at once. Should use :highlight. + doc.body.style.borderTop = "1px solid black"; // FIXME: For cases where completions/MOW are shown at once, or ls=0. Should use :highlight. var items = null; var startIndex = -1; // The index of the first displayed item @@ -1337,7 +1338,8 @@ function ItemList(id) //{{{ div.style.minWidth = document.getElementById("liberator-commandline").scrollWidth + "px"; minHeight = Math.max(minHeight, divNodes.completions.getBoundingClientRect().bottom); container.height = minHeight; - div.style.minWidth = undefined; + if (container.collapsed) + div.style.minWidth = undefined; // FIXME: Belongs elsewhere. commandline.updateOutputHeight(false); } @@ -1415,18 +1417,16 @@ function ItemList(id) //{{{ nodes[i] = row; for (let [i, row] in util.Array.iterator2(nodes)) { - let display = i >= start && i < end; - if (row.parentNode != items) + let display = (i >= start && i < end); + if (display && row.parentNode != items) { do var next = nodes[++i]; while ((!next || next.parentNode != root) && i < nodes.length); items.insertBefore(row, next); } - if (display) - row.style.display = "table-row"; - else - row.style.display = "none"; + else if (!display && row.parentNode == items) + items.removeChild(row); } nodes.up.style.display = (start == 0) ? "none" : "block"; nodes.down.style.display = (end == context.items.length) ? "none" : "block"; @@ -1434,7 +1434,7 @@ function ItemList(id) //{{{ divNodes.noCompletions.style.display = (off > 0) ? "none" : "block"; - completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem' and not(contains(@style, 'none'))]", doc); + completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem']", doc); autoSize(); return true;