Closed GoogleCodeExporter closed 8 years ago
Doing this instead seems to work much more nicely with the undo command:
// Create matcher off of document text
Matcher matcher;
try {
matcher = pattern.matcher(sDoc.getText(0, sDoc.getLength()));
} catch (javax.swing.text.BadLocationException e) {
return;
}
if (matcher == null)
return;
// Loop over matches, replacing text in the widget in a way that plays
// nicely with UndoManager
int offset = 0;
while (matcher.find()) {
int start = matcher.start() + offset;
int end = matcher.end() + offset;
// Offset future selections by difference in text length
offset += replacement.length() - (end-start);
target.select(start, end);
target.replaceSelection(replacement);
}
Original comment by smcal...@gmail.com
on 16 Oct 2009 at 6:10
this seems to be related to issue 112
Original comment by elib...@gmail.com
on 22 Oct 2009 at 7:40
Something similar done.
I did more changes in r117. Will create a binary download shortly.
See issue 88
Original comment by ayman.al...@gmail.com
on 8 Nov 2009 at 10:19
Original issue reported on code.google.com by
smcal...@gmail.com
on 16 Oct 2009 at 5:09