mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Simplify FindReplace.find() logic (part 1)
The snippet: boolean wrapNeeded = false; if (wrap && nextIndex == -1) { // if wrapping, a second chance is ok, start from the end wrapNeeded = true; } is present on both sides of the `if` statement so it can be factored out.
This commit is contained in:
parent
9723726387
commit
47fcff77d5
@ -284,7 +284,6 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private boolean find(boolean wrap, boolean backwards, boolean searchTabs, int originTab) {
|
||||
boolean wrapNeeded = false;
|
||||
String search = findField.getText();
|
||||
|
||||
if (search.length() == 0) {
|
||||
@ -304,10 +303,6 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
int selectionEnd = editor.getCurrentTab().getSelectionStop();
|
||||
|
||||
nextIndex = text.indexOf(search, selectionEnd);
|
||||
if (wrap && nextIndex == -1) {
|
||||
// if wrapping, a second chance is ok, start from beginning
|
||||
wrapNeeded = true;
|
||||
}
|
||||
} else {
|
||||
// int selectionStart = editor.textarea.getSelectionStart();
|
||||
int selectionStart = editor.getCurrentTab().getSelectionStart() - 1;
|
||||
@ -317,10 +312,12 @@ public class FindReplace extends javax.swing.JFrame {
|
||||
} else {
|
||||
nextIndex = -1;
|
||||
}
|
||||
if (wrap && nextIndex == -1) {
|
||||
// if wrapping, a second chance is ok, start from the end
|
||||
wrapNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean wrapNeeded = false;
|
||||
if (wrap && nextIndex == -1) {
|
||||
// if wrapping, a second chance is ok, start from the end
|
||||
wrapNeeded = true;
|
||||
}
|
||||
|
||||
if (nextIndex == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user