diff --git a/src/Text3.cpp b/src/Text3.cpp index ee7865cfa8..5a00ef8bd4 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -54,6 +54,7 @@ #include "insets/InsetCollapsable.h" #include "insets/InsetCommand.h" +#include "insets/InsetExternal.h" #include "insets/InsetFloatList.h" #include "insets/InsetNewline.h" #include "insets/InsetQuotes.h" @@ -850,7 +851,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_INSERT: { cur.recordUndo(); + + // We have to avoid triggering InstantPreview loading + // before inserting into the document. See bug #5626. + bool loaded = bv->buffer().isFullyLoaded(); + bv->buffer().setFullyLoaded(false); Inset * inset = createInset(bv->buffer(), cmd); + bv->buffer().setFullyLoaded(loaded); + if (inset) { // FIXME (Abdel 01/02/2006): // What follows would be a partial fix for bug 2154: @@ -878,7 +886,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cutSelection(cur, true, false); cur.insert(inset); cur.posForward(); + + // trigger InstantPreview now + if (inset->lyxCode() == EXTERNAL_CODE) { + InsetExternal & ins = static_cast(*inset); + ins.updatePreview(); + } } + break; } diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 1fafc96a6e..a3a739222f 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -539,6 +539,12 @@ InsetExternalParams const & InsetExternal::params() const } +void InsetExternal::updatePreview() +{ + setParams(params_); +} + + void InsetExternal::setParams(InsetExternalParams const & p) { params_ = p; diff --git a/src/insets/InsetExternal.h b/src/insets/InsetExternal.h index a9f8adbe53..962ac48de1 100644 --- a/src/insets/InsetExternal.h +++ b/src/insets/InsetExternal.h @@ -107,6 +107,8 @@ public: InsetExternalParams const & params() const; /// void setParams(InsetExternalParams const &); + /// Update not loaded previews + void updatePreview(); /// \returns the number of rows (\n's) of generated code. int latex(odocstream &, OutputParams const &) const; ///