mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-03 05:25:45 +01:00
Fix #285 (Find next doesn't highlight after refresh).
This commit is contained in:
@@ -132,7 +132,9 @@ function Finder() //{{{
|
|||||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
|
||||||
* Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
|
* Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
|
||||||
*/
|
*/
|
||||||
var highlightObj = {
|
var highlighter = {
|
||||||
|
|
||||||
|
doc: null,
|
||||||
|
|
||||||
spans: [],
|
spans: [],
|
||||||
|
|
||||||
@@ -143,16 +145,14 @@ function Finder() //{{{
|
|||||||
finder.caseSensitive = matchCase;
|
finder.caseSensitive = matchCase;
|
||||||
|
|
||||||
var range;
|
var range;
|
||||||
while ((range = finder.Find(aWord,
|
while ((range = finder.Find(aWord, this.searchRange, this.startPt, this.endPt)))
|
||||||
this.searchRange,
|
|
||||||
this.startPt,
|
|
||||||
this.endPt)))
|
|
||||||
yield range;
|
yield range;
|
||||||
},
|
},
|
||||||
|
|
||||||
highlightDoc: function highlightDoc(win, aWord)
|
highlightDoc: function highlightDoc(win, aWord)
|
||||||
{
|
{
|
||||||
Array.forEach(win.frames, function (frame) highlightObj.highlightDoc(frame, aWord));
|
this.doc = content.document; // XXX
|
||||||
|
Array.forEach(win.frames, function (frame) highlighter.highlightDoc(frame, aWord));
|
||||||
|
|
||||||
var doc = win.document;
|
var doc = win.document;
|
||||||
if (!doc || !(doc instanceof HTMLDocument))
|
if (!doc || !(doc instanceof HTMLDocument))
|
||||||
@@ -160,7 +160,7 @@ function Finder() //{{{
|
|||||||
|
|
||||||
if (!aWord)
|
if (!aWord)
|
||||||
{
|
{
|
||||||
let elems = highlightObj.getSpans(doc);
|
let elems = highlighter.spans;
|
||||||
for (let i = elems.length; --i >= 0;)
|
for (let i = elems.length; --i >= 0;)
|
||||||
{
|
{
|
||||||
let elem = elems[i];
|
let elem = elems[i];
|
||||||
@@ -249,7 +249,7 @@ function Finder() //{{{
|
|||||||
this.spans = [];
|
this.spans = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
getSpans: function (doc) this.spans
|
isHighlighted: function (doc) this.doc == doc && this.spans.length > 0
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -490,14 +490,13 @@ function Finder() //{{{
|
|||||||
if (config.name == "Muttator")
|
if (config.name == "Muttator")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// already highlighted?
|
if (highlighter.isHighlighted(content.document))
|
||||||
if (highlightObj.getSpans(content.document).length > 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
str = lastSearchString;
|
str = lastSearchString;
|
||||||
|
|
||||||
highlightObj.highlightDoc(window.content, str);
|
highlighter.highlightDoc(window.content, str);
|
||||||
|
|
||||||
// recreate selection since _highlightDoc collapses the selection backwards
|
// recreate selection since _highlightDoc collapses the selection backwards
|
||||||
getBrowser().fastFind.findAgain(false, linksOnly);
|
getBrowser().fastFind.findAgain(false, linksOnly);
|
||||||
@@ -510,7 +509,7 @@ function Finder() //{{{
|
|||||||
*/
|
*/
|
||||||
clear: function ()
|
clear: function ()
|
||||||
{
|
{
|
||||||
highlightObj.clear();
|
highlighter.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
|
|||||||
Reference in New Issue
Block a user