diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/content/buffer.js | 14 | ||||
-rw-r--r-- | common/content/tabs.js | 16 |
2 files changed, 21 insertions, 9 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js index 3c5f9cb8..b65a657b 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1600,13 +1600,21 @@ var Buffer = Module("buffer", { }); context.pushProcessor(0, function (item, text, next) <> - <span highlight="Indicator" style="display: inline-block;">{item.item.indicator}</span> + <span highlight="Indicator" style="display: inline-block;">{item.indicator}</span> { next.call(this, item, text) } </>); context.process[1] = function (item, text) template.bookmarkDescription(item, template.highlightFilter(text, this.filter)); context.anchored = false; - context.keys = { text: "text", description: "url", icon: "icon", id: "id", command: function () "tabs.select" }; + context.keys = { + text: "text", + description: "url", + indicator: function (item) item.tab === tabs.getTab() ? "%" : + item.tab === tabs.alternate ? "#" : " ", + icon: "icon", + id: "id", + command: function () "tabs.select" + }; context.compare = CompletionContext.Sort.number; context.filters = [CompletionContext.Filter.textDescription]; @@ -1627,9 +1635,9 @@ var Buffer = Module("buffer", { return { text: [i + ": " + (tab.label || "(Untitled)"), i + ": " + url], + tab: tab, id: i - 1, url: url, - indicator: indicator, icon: tab.image || DEFAULT_FAVICON }; }); diff --git a/common/content/tabs.js b/common/content/tabs.js index e7754fe1..4053db0b 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -456,8 +456,8 @@ var Tabs = Module("tabs", { if (buffer == "#") return tabs.selectAlternateTab(); - count = Math.max(1, count || 1); reverse = Boolean(reverse); + count = Math.max(1, count || 1) * (1 + -2 * reverse); let matches = buffer.match(/^(\d+):?/); if (matches) @@ -467,17 +467,21 @@ var Tabs = Module("tabs", { if (matches) return tabs.select(matches, false); - matches = completion.runCompleter("buffer", buffer); + matches = completion.runCompleter("buffer", buffer).map(function (obj) obj.tab); if (matches.length == 0) dactyl.echoerr("E94: No matching buffer for " + buffer); else if (matches.length > 1 && !allowNonUnique) dactyl.echoerr("E93: More than one match for " + buffer); else { - let index = (count - 1) % matches.length; - if (reverse) - index = matches.length - index - 1; - tabs.select(matches[index].id, false); + let start = matches.indexOf(tabs.getTab()); + if (start == -1 && reverse) + start++; + + let index = (start + count) % matches.length; + if (index < 0) + index = matches.length + index; + tabs.select(matches[index], false); } }, |