Skip to content

Commit 0e16ccc

Browse files
committed
Fixed crash issue with List & improved simple lists.
Signed-off-by: Grant Skinner <[email protected]>
1 parent 4fe83f2 commit 0e16ccc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

js/documentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var library = {
6969
{
7070
label:"List",
7171
desc:"The <b>List</b> tool lists all found matches."+
72-
"<p>You can specify either a simple delimiter (ex. <code>,</code> or <code>\\n</code>), or use <a href='javascript:showLib(\"subst\")'>substitution tokens</a> (ex. <code>$&</code> or <code>$1</code>) to generate more advanced reports.</p>"+
72+
"<p>You can specify either a simple delimiter (ex. <code>,</code> or <code>\\n</code>), or use <a href='javascript:showLib(\"subst\")'>substitution tokens</a> to generate more advanced reports. For example, <code>$1\\n</code> would list all group 1 results.</p>"+
7373
"<p>Escaped characters compatible with the JS string format are supported, such as <code>\\n</code>, <code>\\t</code> & <code>\\u0009</code>.</p>"+
7474
"<p>Roll over tokens for information.</p>"
7575
},

js/views/DocView.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,16 +608,21 @@ p.updateTool = function (source, regex) {
608608
if (this.tool == "replace") {
609609
result = source.replace(regex || this.getRegEx(), str);
610610
} else {
611-
var repl, ref, regex = this.getRegEx(false);
612-
if (str.search(/\$[&1-9`']/) === -1) { str = "$&"+str; }
611+
var repl, ref, regex = this.getRegEx(false), lastIndex = -1, trimR = 0;
612+
if (str.search(/\$[&1-9`']/) === -1) {
613+
trimR = str.length;
614+
str = "$&"+str;
615+
}
613616
while (true) {
614617
ref = source.replace(regex, "\b");
615618
var index = ref.indexOf("\b");
616-
if (index === -1) { break; }
619+
if (index === -1 || index === lastIndex) { break; }
617620
repl = source.replace(regex, str);
618621
result += repl.substr(index, repl.length-ref.length+1);
619622
source = ref.substr(index+1);
623+
lastIndex = index;
620624
}
625+
if (trimR) { result = result.substr(0,result.length-trimR); }
621626
}
622627
}
623628
this.toolsOutCM.setValue(result);

0 commit comments

Comments
 (0)