]> git.lyx.org Git - features.git/commitdiff
Move some processing from the loop into the main InsetText routine.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 12 Nov 2020 21:33:28 +0000 (16:33 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 13 Nov 2020 00:27:28 +0000 (19:27 -0500)
src/insets/Inset.h
src/insets/InsetText.cpp
src/insets/InsetText.h

index c6fbfdb2c0affb44db7357f1d69c143c0e1b4484..7885046ad7979803750532c1baef2e33b7f7aaf0 100644 (file)
@@ -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;
index 9c32d491e07eead0121b956d5415ad114aa4e1eb..95768ae1ca89a88efd143cd2a053d51a61b193fa 100644 (file)
@@ -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
index 9fdfb6fdfed4892930d6d489ad5150973f72db0b..079d0f4ae5e6a03168225c1acddaab86cffbe7f0 100644 (file)
@@ -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);
        ///