From 22ca29f722c0e66129bdbc3d630e55289f6785d6 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Thu, 12 Nov 2020 16:33:28 -0500 Subject: [PATCH] Move some processing from the loop into the main InsetText routine. --- src/insets/Inset.h | 3 +++ src/insets/InsetText.cpp | 21 +++++---------------- src/insets/InsetText.h | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/insets/Inset.h b/src/insets/Inset.h index c6fbfdb2c0..7885046ad7 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -571,6 +571,9 @@ public: /// The boolean indicates whether we are preparing for output, e.g., /// of XHTML. virtual void updateBuffer(ParIterator const &, UpdateType, bool const) {} + /// Note that \param us is expected to be a DocIterator pointing at this inset. + /// We will assert otherwise. + virtual void updateMacros(DocIterator const & /* us */, DocIterator const & /* scope */) {} /// Updates the inset's dialog virtual Buffer const * updateFrontend() const; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 9c32d491e0..95768ae1ca 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -922,7 +922,6 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) DocIterator it = us; pit_type const lastpit = it.lastpit(); - // look for macros in each paragraph while (it.pit() <= lastpit) { Paragraph & par = it.paragraph(); @@ -931,20 +930,10 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) for (auto const & insit : par.insetList()) { it.pos() = insit.pos; - if (InsetText const * itext = insit.inset->asInsetText()) { + if (InsetText * itext = insit.inset->asInsetText()) { // collect macros in inset it.push_back(CursorSlice(*insit.inset)); - if (itext->producesOutput()) { - // the simple case - updateMacros(it, scope); - } else { - // We don't want macros declared in notes, comments, etc, - // to affect anything outside them. - // New scope which ends just behind the inset - DocIterator new_scope = it; - ++new_scope.pos(); - updateMacros(it, new_scope); - } + itext->updateMacros(it, ourscope); it.pop_back(); continue; } @@ -954,7 +943,7 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) size_t const numcells = slice.nargs(); for (; slice.idx() < numcells; slice.forwardIdx()) { it.push_back(slice); - updateMacros(it, scope); + updateMacros(it, ourscope); it.pop_back(); } continue; @@ -970,7 +959,7 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) buffer().clearMacroLock(); if (!child) continue; - buffer().registerChild(child, it, scope); + buffer().registerChild(child, it, ourscope); continue; } @@ -999,7 +988,7 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) continue; // register macro - buffer().registerMacro(macroTemplate.name(), it, scope); + buffer().registerMacro(macroTemplate.name(), it, ourscope); } // next paragraph diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 9fdfb6fdfe..079d0f4ae5 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -173,7 +173,7 @@ public: /// Update the counters of this inset and of its contents void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override; /// - void updateMacros(DocIterator const & us, DocIterator const & scope); + void updateMacros(DocIterator const & us, DocIterator const & scope) override; /// void setMacrocontextPositionRecursive(DocIterator const & pos); /// -- 2.39.5