mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 20:27:57 +01:00
better tab completion for URL commands, tokenize "filter" on \s+ and match each of the tokens
This commit is contained in:
3
NEWS
3
NEWS
@@ -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
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -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)
|
|
||||||
|
if (filter.split(/\s+/).every(function(str) { return items_str.indexOf(str) > -1; }))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user