1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Fix search and replace #2106

This commit is contained in:
Fulvio Ieva 2014-07-24 10:52:56 +02:00 committed by Cristian Maglie
parent 6efbecd3cc
commit cd75cc24a2

View File

@ -426,8 +426,23 @@ public class FindReplace extends JFrame implements ActionListener {
public void replace() { public void replace() {
if(findField.getText().length()==0) if(findField.getText().length()==0)
return; 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 ) { while ( true ) {
if ( find(false,false,searchAllFiles,-1)) { if ( find(false,false,searchAllFiles,-1)) {
foundAtLeastOne = true; foundAtLeastOne = true;
replace(); editor.setSelectedText(replaceField.getText());
editor.getSketch().setModified(true); // TODO is this necessary?
} else { } else {
break; break;
} }