Fix bug #6217: Replacing a word in spellcheck does not update toolbar

Use the dispatch machinery when replacing a word in the spellchecker. Note that this implies a slight hack with lyxrc.auto_region_delete setting.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33445 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2010-02-12 11:25:44 +00:00
parent d1f2c9570b
commit 09ef9c67ef

View File

@ -204,13 +204,16 @@ void GuiSpellchecker::on_replacePB_clicked()
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();