mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Fix search and replace #2106
This commit is contained in:
parent
6efbecd3cc
commit
cd75cc24a2
@ -426,8 +426,23 @@ public class FindReplace extends JFrame implements ActionListener {
|
||||
public void replace() {
|
||||
if(findField.getText().length()==0)
|
||||
return;
|
||||
editor.setSelectedText(replaceField.getText());
|
||||
editor.getSketch().setModified(true); // TODO is this necessary?
|
||||
|
||||
int newpos = editor.getSelectionStart() - findField.getText().length();
|
||||
if (newpos < 0) newpos = 0;
|
||||
editor.setSelection(newpos, newpos);
|
||||
|
||||
boolean foundAtLeastOne = false;
|
||||
|
||||
if ( find(false,false,searchAllFiles,-1)) {
|
||||
foundAtLeastOne = true;
|
||||
editor.setSelectedText(replaceField.getText());
|
||||
editor.getSketch().setModified(true); // TODO is this necessary?
|
||||
}
|
||||
|
||||
if ( !foundAtLeastOne ) {
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,7 +468,8 @@ public class FindReplace extends JFrame implements ActionListener {
|
||||
while ( true ) {
|
||||
if ( find(false,false,searchAllFiles,-1)) {
|
||||
foundAtLeastOne = true;
|
||||
replace();
|
||||
editor.setSelectedText(replaceField.getText());
|
||||
editor.getSketch().setModified(true); // TODO is this necessary?
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user