]> git.lyx.org Git - features.git/commitdiff
The isMacroScope method is just !producesOutput (or should be).
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 6 Nov 2020 16:41:20 +0000 (11:41 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Wed, 11 Nov 2020 17:07:56 +0000 (12:07 -0500)
So remove that, and restructure the code a bit.

src/Buffer.cpp
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetText.h

index 23f6315f5f63dc69cdc1878977dc6112883a3751..9562cb8c72eca39f98b48c9a9baab7146542a1c8 100644 (file)
@@ -3730,19 +3730,20 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                for (auto const & insit : par.insetList()) {
                        it.pos() = insit.pos;
 
-                       // is it a nested text inset?
-                       if (insit.inset->asInsetText()) {
-                               // Inset needs its own scope?
-                               InsetText const * itext = insit.inset->asInsetText();
-                               bool newScope = itext->isMacroScope();
-
-                               // scope which ends just behind the inset
-                               DocIterator insetScope = it;
-                               ++insetScope.pos();
-
+                       if (InsetText const * itext = insit.inset->asInsetText()) {
                                // collect macros in inset
                                it.push_back(CursorSlice(*insit.inset));
-                               updateMacros(it, newScope ? insetScope : scope);
+                               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);
+                               }
                                it.pop_back();
                                continue;
                        }
index a70ff27463c6db5003efc637d6e33315d02aff80..17e8007d39aa7a4c1f6e50925f7da74cc47118c8 100644 (file)
@@ -381,13 +381,6 @@ string InsetBranch::contextMenuName() const
 }
 
 
-bool InsetBranch::isMacroScope() const
-{
-       // Its own scope if not selected by buffer
-       return !producesOutput();
-}
-
-
 string InsetBranch::params2string(InsetBranchParams const & params)
 {
        ostringstream data;
index 6106ce5a5c3babbd8923c8783d5e2a2d59cf9b6b..27464855d6bffca4a8c8d746cea27db36550ac69 100644 (file)
@@ -104,8 +104,6 @@ private:
        ///
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
        ///
-       bool isMacroScope() const override;
-       ///
        docstring toolTip(BufferView const & bv, int x, int y) const override;
        ///
        bool usePlainLayout() const override { return false; }
index fa84c61c87c7df75914027e180e48e0fff6e3be2..5717febf4fdb7e50794ce05f008dcf2043a3750f 100644 (file)
@@ -198,16 +198,6 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-bool InsetNote::isMacroScope() const
-{
-       // LyX note has no latex output
-       if (params_.type == InsetNoteParams::Note)
-               return true;
-
-       return InsetCollapsible::isMacroScope();
-}
-
-
 void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
index aeab8f038b282084ec43a7636b4ffacfd500efb0..b69850568023b4222198fac9bdccae5dd1401356 100644 (file)
@@ -79,8 +79,6 @@ private:
        /// show the note dialog
        bool showInsetDialog(BufferView * bv) const override;
        ///
-       bool isMacroScope() const override;
-       ///
        void latex(otexstream &, OutputParams const &) const override;
        ///
        int plaintext(odocstringstream & ods, OutputParams const & op,
index d571806ba66f9a8ae272b2f378fb27f10018f756..cefd44cabf0bb198d0e0c66c70c0882ad38942fa 100644 (file)
@@ -156,8 +156,6 @@ public:
        ///
        bool allowSpellCheck() const override { return getLayout().spellcheck() && !getLayout().isPassThru(); }
        ///
-       virtual bool isMacroScope() const { return false; }
-       ///
        bool allowMultiPar() const override { return getLayout().isMultiPar(); }
        ///
        bool isInTitle() const override { return intitle_context_; }