diff --git a/common/content/buffer.js b/common/content/buffer.js index b56c571b..27f2114f 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -292,7 +292,7 @@ const Buffer = Module("buffer", { // Workaround for bugs 591425 and 606877, dactyl bug #81 config.browser.mCurrentBrowser.collapsed = - uri.scheme === "dactyl" && webProgress.isLoadingDocument; + uri && uri.scheme === "dactyl" && webProgress.isLoadingDocument; util.timeout(function () { autocommands.trigger("LocationChange", { url: buffer.URL }); @@ -480,8 +480,6 @@ const Buffer = Module("buffer", { * * @returns {string} */ - // FIXME: getSelection() doesn't always preserve line endings, see: - // https://www.mozdev.org/bugs/show_bug.cgi?id=19303 getCurrentWord: function () { let win = buffer.focusedFrame || window.content; let selection = win.getSelection(); @@ -1688,11 +1686,11 @@ const Buffer = Module("buffer", { // reloading mappings.add(myModes, ["r"], "Reload the current web page", - function () { tabs.reload(config.browser.mCurrentTab, false); }); + function () { tabs.reload(tabs.getTab(), false); }); mappings.add(myModes, ["R"], "Reload while skipping the cache", - function () { tabs.reload(config.browser.mCurrentTab, true); }); + function () { tabs.reload(tabs.getTab(), true); }); // yanking mappings.add(myModes, ["Y"], diff --git a/common/content/completion.js b/common/content/completion.js index bd5c536e..d5922404 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -864,6 +864,16 @@ const Completion = Module("completion", { if (complete == null) complete = options["complete"]; + if (/^about:/.test(context.filter)) { + context.fork("about", 6, this, function (context) { + context.generate = function () { + const PREFIX = "@mozilla.org/network/protocol/about;1?what="; + return [[k.substr(PREFIX.length), ""] for (k in Cc) if (k.indexOf(PREFIX) == 0)] + } + }); + } + + // Will, and should, throw an error if !(c in opts) Array.forEach(complete, function (c) { let completer = completion.urlCompleters[c]; diff --git a/common/content/io.js b/common/content/io.js index 844b3c2c..3148c30d 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -209,6 +209,18 @@ const IO = Module("io", { return io.File(file); }, + isJarURL: function (url) { + try { + let uri = util.newURI(url); + let channel = services.io.newChannelFromURI(uri); + channel.cancel(Cr.NS_BINDING_ABORTED); + if (channel instanceof Ci.nsIJARChannel) + return channel.QueryInterface(Ci.nsIJARChannel); + } + catch (e) {} + return false; + }, + readHeredoc: function (end) { return ""; }, @@ -654,7 +666,12 @@ lookup: completion.file = function file(context, full, dir) { // dir == "" is expanded inside readDirectory to the current dir - [dir] = (dir || context.filter).match(/^(?:.*[\/\\])?/); + function getDir(str) str.match(/^(?:.*[\/\\])?/)[0]; + dir = getDir(dir || context.filter); + + let file = util.getFile(dir); + if (file && file.exists() && !file.isDirectory()) + file = file.parent; if (!full) context.advance(dir.length); @@ -677,13 +694,40 @@ lookup: // context.background = true; context.key = dir; - context.generate = function generate_file() { - try { - return io.File(dir).readDirectory(); - } - catch (e) {} - return []; - }; + let channel = io.isJarURL(dir); + if (channel) + context.generate = function generate_jar() { + let uri = channel.URI.QueryInterface(Ci.nsIJARURI); + let file = util.getFile(uri.JARFile); + if (file) { + // let jar = services.zipReader.getZip(file); Crashes. + let jar = services.ZipReader(file); + try { + let path = decodeURI(getDir(uri.JAREntry)); + return [ + { + isDirectory: function () s.substr(-1) == "/", + leafName: /([^\/]*)\/?$/.exec(s)[1] + } + for (s in iter(jar.findEntries("*"))) if (s.indexOf(path) == 0) + ] + } + finally { + jar.close(); + } + } + }; + else + context.generate = function generate_file() { + try { + util.dump(String(file), file && file.path); + return io.File(file || dir).readDirectory(); + } + catch (e) { + util.reportError(e); + } + return []; + }; }; completion.runtime = function (context) { @@ -715,7 +759,17 @@ lookup: }; completion.addUrlCompleter("f", "Local files", function (context, full) { - if (/^(\.{0,2}|~)\/|^file:/.test(context.filter)) + let match = /^(chrome:\/\/[^\/]+\/)([^/]*)$/.exec(context.filter); + if (match) { + context.key = match[1]; + context.advance(match[1].length); + context.generate = function () iter({ + content: "Chrome content", + locale: "Locale-specific content", + skin: "Theme-specific content" + }); + } + else if (/^(\.{0,2}|~)\/|^file:/.test(context.filter) || util.getFile(context.filter) || io.isJarURL(context.filter)) completion.file(context, full); }); }, diff --git a/common/content/modes.js b/common/content/modes.js index 1e66cb1f..4f352bb7 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -23,10 +23,8 @@ const Modes = Module("modes", { this._modeStack = update([], { pop: function pop() { - if (this.length <= 1) { - util.dumpStack("Trying to pop last element in mode stack"); + if (this.length <= 1) throw Error("Trying to pop last element in mode stack"); - } return pop.superapply(this, arguments); } }); @@ -47,7 +45,7 @@ const Modes = Module("modes", { if (selection && !selection.isCollapsed) selection.collapseToStart(); } - else + else if (stack.pop) editor.unselectText(); } }); @@ -96,10 +94,12 @@ const Modes = Module("modes", { dactyl.focusContent(true); if (prev.main == modes.NORMAL) { dactyl.focusContent(true); - // clear any selection made - let selection = window.content.getSelection(); - if (selection && !selection.isCollapsed) - selection.collapseToStart(); + for (let frame in values(buffer.allFrames())) { + // clear any selection made + let selection = frame.getSelection(); + if (selection && !selection.isCollapsed) + selection.collapseToStart(); + } } } diff --git a/common/content/tabs.js b/common/content/tabs.js index 938b1e65..f2be4187 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -445,7 +445,7 @@ const Tabs = Module("tabs", { else { let index = (count - 1) % matches.length; if (reverse) - index = matches.length - count; + index = matches.length - index - 1; tabs.select(matches[index].id, false); } }, diff --git a/common/locale/en-US/various.xml b/common/locale/en-US/various.xml index a491b58c..db65a99e 100644 --- a/common/locale/en-US/various.xml +++ b/common/locale/en-US/various.xml @@ -195,10 +195,11 @@
@@ -235,7 +236,7 @@
Available actions:
-