#include "lyxtext.h"
#include "lyxfind.h"
+#include "paragraph.h"
#include "frontends/LyXView.h"
#include "frontends/Alert.h"
#include "support/textutils.h"
#include "buffer.h"
#include "debug.h"
#include "gettext.h"
+#include "insets/insettext.h"
using lyx::pos_type;
int replace_count = 0;
do {
text = bv->getLyXText();
- bv->hideCursor();
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
- bv->toggleSelection(false);
- text->replaceSelectionWithString(bv, replacestr);
- text->setSelectionOverString(bv, replacestr);
- bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- ++replace_count;
+ // We have to do this check only because mathed insets don't
+ // return their own LyXText but the LyXText of it's parent!
+ if (!bv->theLockingInset() ||
+ ((text != bv->text) &&
+ (text->inset_owner == text->inset_owner->getLockingInset())))
+ {
+ bv->hideCursor();
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->toggleSelection(false);
+ text->replaceSelectionWithString(bv, replacestr);
+ text->setSelectionOverString(bv, replacestr);
+ bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ ++replace_count;
+ }
if (!once)
found = LyXFind(bv, searchstr, fw, casesens, matchwrd);
} while (!once && replaceall && found);