mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #2188 from Manindra29/findReplaceILfix
Fixes #2082, Find Replace infinite loop
This commit is contained in:
@@ -454,9 +454,22 @@ public class FindReplace extends JFrame {
|
||||
editor.setSelection(0, 0);
|
||||
|
||||
boolean foundAtLeastOne = false;
|
||||
while (true) {
|
||||
int startTab = -1, startIndex = -1, c = 50000;
|
||||
// you couldn't seriously be replacing 50K times o_O
|
||||
while (--c > 0) {
|
||||
if (find(false, false)) {
|
||||
foundAtLeastOne = true;
|
||||
if(editor.getSketch().getCurrentCodeIndex() == startTab
|
||||
&& editor.getSelectionStart() == startIndex){
|
||||
// we've reached where we started, so stop the replace
|
||||
Toolkit.beep();
|
||||
editor.statusNotice("Reached beginning of search!");
|
||||
break;
|
||||
}
|
||||
if(!foundAtLeastOne){
|
||||
foundAtLeastOne = true;
|
||||
startTab = editor.getSketch().getCurrentCodeIndex();
|
||||
startIndex = editor.getSelectionStart();
|
||||
}
|
||||
replace();
|
||||
} else {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user