1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 22:37:58 +01:00

better tab completion for URL commands, tokenize "filter" on \s+ and match each of the tokens

This commit is contained in:
Martin Stubenschrott
2007-10-18 17:38:59 +00:00
parent 129f7f23f7
commit 9dfc4a7d40
3 changed files with 16 additions and 16 deletions

3
NEWS
View File

@@ -2,6 +2,9 @@
2007-xx-xx: 2007-xx-xx:
* version 0.6 * version 0.6
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0
* :open,:bmarks,etc. filter on space seperated tokens now, so you can
search with :open linux windows <tab> all your bookmarks/history
which contain linux AND windows in the url or title
* :ls, :history and :bmarks output is now hyperlinked * :ls, :history and :bmarks output is now hyperlinked
* tags and keyword support for :bmark * tags and keyword support for :bmark
* added full zoom, and changed keybindings slightly for text zoom * added full zoom, and changed keybindings slightly for text zoom

View File

@@ -283,7 +283,7 @@ function Bookmarks() //{{{
if (items.length == 0) if (items.length == 0)
{ {
if (filter.length > 0) if (filter.length > 0 || tags.length > 0)
vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\""); vimperator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
else else
vimperator.echoerr("No bookmarks set"); vimperator.echoerr("No bookmarks set");

View File

@@ -531,7 +531,11 @@ vimperator.completion = (function() // {{{
if (url.indexOf(filter) == -1) if (url.indexOf(filter) == -1)
{ {
if (title.indexOf(filter) >= 0) // no direct match of filter in the url, but still accept this item
// if _all_ tokens of filter match either the url or the title
if (filter.split(/\s+/).every(function(token) {
return (url.indexOf(token) > -1 || title.indexOf(token) > -1);
}))
additional_completions.push(urls[i]); additional_completions.push(urls[i]);
continue; continue;
@@ -571,23 +575,16 @@ vimperator.completion = (function() // {{{
if (typeof(filter) != "string" || !items) if (typeof(filter) != "string" || !items)
return false; return false;
if (case_sensitive) var items_str = items.join(" ");
{ if (!case_sensitive)
for (var i = 0; i < items.length; i++)
{
if (items[i].indexOf(filter) > -1)
return true;
}
}
else
{ {
filter = filter.toLowerCase(); filter = filter.toLowerCase();
for (var i = 0; i < items.length; i++) items_str = items_str.toLowerCase();
{
if (items[i].toLowerCase().indexOf(filter) > -1)
return true;
}
} }
if (filter.split(/\s+/).every(function(str) { return items_str.indexOf(str) > -1; }))
return true;
return false; return false;
}, },