diff --git a/common/content/completion.js b/common/content/completion.js index 33bca05e..fc87257c 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -279,10 +279,11 @@ const CompletionContext = Class("CompletionContext", { delete this.cache.filtered; delete this.cache.filter; this.cache.rows = []; - this.hasItems = items.length > 0; this._completions = items; this.itemCache[this.key] = items; } + if (this._completions) + this.hasItems = this._completions.length > 0; if (this.updateAsync && !this.noUpdate) util.callInMainThread(function () { this.onUpdate(); }, this); }, diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index 0f966f90..b8eb0a79 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -294,6 +294,7 @@ const Highlights = Module("Highlight", { let hl = highlight.get(args[0]); if (hl) context.completions = [[hl.value, "Current Value"], [hl.default || "", "Default Value"]]; + context.fork("css", 0, modules.completion, "css"); } }, hereDoc: true, diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index 997f4419..9feada0e 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -301,6 +301,7 @@ const Styles = Module("Styles", { let sheet = styles.get(false, args["-name"]); if (sheet) context.completions = [[sheet.css, "Current Value"]]; + context.fork("css", 0, modules.completion, "css"); } }, hereDoc: true, @@ -378,6 +379,44 @@ const Styles = Module("Styles", { }); }); }, + completion: function (dactyl, modules, window) { + const names = Array.slice(util.computedStyle(window.document.createElement("div"))); + const string = /(?:"(?:[^\\"]|\\.)*(?:"|$)|'(?:[^\\']|\\.)*(?:'|$))/.source; + const pattern = RegExp(String.replace(, /S/g, string).replace(/\s*/g, ""), "gi"); + modules.completion.css = function (context) { + context.title = ["Property"]; + context.keys = { text: function (p) p + ":", description: function () "" }; + + pattern.lastIndex = 0; + let match, lastMatch; + while ((!match || match[0]) && (match = pattern.exec(context.filter)) && (match[0].length || !lastMatch)) + lastMatch = match; + if (lastMatch != null && !lastMatch[3] && !lastMatch[4]) { + context.advance(lastMatch.index + lastMatch[1].length) + context.completions = names; + } + }; + }, javascript: function (dactyl, modules, window) { modules.JavaScript.setCompleter(["get", "addSheet", "removeSheet", "findSheets"].map(function (m) styles[m]), [ // Prototype: (system, name, filter, css, index)