mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-27 21:54:30 +01:00
Fix search and replace #2106
This commit is contained in:
parent
6efbecd3cc
commit
cd75cc24a2
@ -426,10 +426,25 @@ 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;
|
||||||
|
|
||||||
|
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.setSelectedText(replaceField.getText());
|
||||||
editor.getSketch().setModified(true); // TODO is this necessary?
|
editor.getSketch().setModified(true); // TODO is this necessary?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !foundAtLeastOne ) {
|
||||||
|
Toolkit.getDefaultToolkit().beep();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the current selection with whatever's in the
|
* Replace the current selection with whatever's in the
|
||||||
* replacement text field, and then find the next match
|
* replacement text field, and then find the next match
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user