docstring const replacement = qstring_to_ucs4(d->ui.replaceCO->currentText());
LYXERR(Debug::GUI, "Replace (" << replacement << ")");
- BufferView * bv = const_cast<BufferView *>(bufferview());
- if (!bv->cursor().inTexted())
- return;
- cap::replaceSelectionWithString(bv->cursor(), replacement, true);
- bv->buffer().markDirty();
- // If we used an LFUN, we would not need that
- bv->processUpdateFlags(Update::Force | Update::FitCursor);
+ /*
+ Slight hack ahead: we want to use the dispatch machinery
+ (see bug #6217), but self-insert honors the ``auto region
+ delete'' setting, which is not wanted here. Creating a new
+ ad-hoc LFUN seems overkill, but it could be an option (JMarc).
+ */
+ bool const ard = lyxrc.auto_region_delete;
+ lyxrc.auto_region_delete = true;
+ dispatch(FuncRequest(LFUN_SELF_INSERT, replacement));
+ lyxrc.auto_region_delete = ard;
// fix up the count
--d->count_;
check();