1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-11 11:05:46 +01:00

Enable 'hlf' for regexp find.

This commit is contained in:
Kris Maglione
2011-09-26 18:42:59 -04:00
parent 59daca20ba
commit e5230c992e
2 changed files with 27 additions and 17 deletions

View File

@@ -976,10 +976,7 @@
<type>&option.hlfind.type;</type> <type>&option.hlfind.type;</type>
<default>&option.hlfind.default;</default> <default>&option.hlfind.default;</default>
<description> <description>
<p> <p>Highlight previous find pattern matches.</p>
Highlight previous find pattern matches. This functionality is not
currently available for regular expression searches.
</p>
</description> </description>
</item> </item>

View File

@@ -359,6 +359,8 @@ var RangeFind = Class("RangeFind", {
get findString() this.lastString, get findString() this.lastString,
get flags() this.matchCase ? "" : "i",
get selectedRange() { get selectedRange() {
let win = this.store.focusedFrame && this.store.focusedFrame.get() || this.content; let win = this.store.focusedFrame && this.store.focusedFrame.get() || this.content;
@@ -441,9 +443,6 @@ var RangeFind = Class("RangeFind", {
this.highlighted = null; this.highlighted = null;
} }
else { else {
if (this.regexp)
return;
this.selections = []; this.selections = [];
let string = this.lastString; let string = this.lastString;
for (let r in this.iter(string)) { for (let r in this.iter(string)) {
@@ -485,14 +484,29 @@ var RangeFind = Class("RangeFind", {
}, },
iter: function (word) { iter: function (word) {
let saved = ["lastRange", "lastString", "range"].map(function (s) [s, this[s]], this); let saved = ["lastRange", "lastString", "range", "regexp"].map(function (s) [s, this[s]], this);
let res;
try { try {
this.range = this.ranges[0];
this.lastRange = null; this.lastRange = null;
this.lastString = word; if (this.regexp) {
var res; let re = RegExp(word, "gm" + this.flags);
while (res = this.find(null, this.reverse, true)) this.regexp = false;
yield res; for (this.range in array.iterValues(this.ranges)) {
for (let match in util.regexp.iterate(re, DOM.stringify(this.range.range, true))) {
let lastRange = this.lastRange;
if (res = this.find(null, this.reverse, true))
yield res;
else
this.lastRange = lastRange;
}
}
}
else {
this.range = this.ranges[0];
this.lastString = word;
while (res = this.find(null, this.reverse, true))
yield res;
}
} }
finally { finally {
saved.forEach(function ([k, v]) this[k] = v, this); saved.forEach(function ([k, v]) this[k] = v, this);
@@ -627,7 +641,6 @@ var RangeFind = Class("RangeFind", {
if (this.regexp) if (this.regexp)
try { try {
var flags = this.matchCase ? "" : "i";
RegExp(pattern); RegExp(pattern);
} }
catch (e) { catch (e) {
@@ -658,11 +671,11 @@ var RangeFind = Class("RangeFind", {
range = DOM.stringify(range); range = DOM.stringify(range);
if (!this.backward) if (!this.backward)
var match = RegExp(pattern, "m" + flags).exec(range); var match = RegExp(pattern, "m" + this.flags).exec(range);
else { else {
match = RegExp("[^]*(?:" + pattern + ")", "m" + flags).exec(range); match = RegExp("[^]*(?:" + pattern + ")", "m" + this.flags).exec(range);
if (match) if (match)
match = RegExp(pattern + "$", flags).exec(match[0]); match = RegExp(pattern + "$", this.flags).exec(match[0]);
} }
if (!(match && match[0])) if (!(match && match[0]))
continue; continue;