1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 12:27:59 +01:00

Fix search.highlight to prevent rehighlighting on n/N.

This commit is contained in:
Doug Kearns
2009-05-11 16:08:11 +10:00
parent f73879f43e
commit 37c466b441

View File

@@ -137,7 +137,9 @@ function Search() //{{{
* Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk> * Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
*/ */
var highlightObj = { var highlightObj = {
spans: [], spans: [],
search: function (aWord, matchCase) search: function (aWord, matchCase)
{ {
var finder = services.create("find"); var finder = services.create("find");
@@ -163,7 +165,7 @@ function Search() //{{{
if (!aWord) if (!aWord)
{ {
let elems = highlightObj.getSpans(doc); let elems = highlightObj.getSpans(doc);
for (let i = elems.snapshotLength; --i >= 0;) for (let i = elems.length; --i >= 0;)
{ {
let elem = elems.snapshotItem(i); let elem = elems.snapshotItem(i);
let docfrag = doc.createDocumentFragment(); let docfrag = doc.createDocumentFragment();
@@ -250,6 +252,7 @@ function Search() //{{{
}) })
this.spans = [] this.spans = []
}, },
getSpans: function (doc) this.spans getSpans: function (doc) this.spans
}; };
@@ -461,9 +464,9 @@ function Search() //{{{
if (typeof forcedBackward === "boolean") if (typeof forcedBackward === "boolean")
backwards = forcedBackward; backwards = forcedBackward;
//Allow /<CR> to work. // Allow /<CR> to work.
if ((!command) || command == lastSearchPattern) if (!command)
return this.findAgain(backwards != lastSearchBackwards) command = lastSearchPattern;
this.clear(); this.clear();
@@ -507,7 +510,7 @@ function Search() //{{{
return; return;
// already highlighted? // already highlighted?
if (highlightObj.getSpans(content.document).snapshotLength > 0) if (highlightObj.getSpans(content.document).length > 0)
return; return;
if (!str) if (!str)