]> 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)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Sun, 8 Nov 2020 07:55:26 +0000 (09:55 +0200)
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 acda58f46fc4a4ab7f2f586fec6c1458ac95fefe..44b3178bf46b13d2dfc9de1ff87bcc1c10eede52 100644 (file)
@@ -3734,16 +3734,20 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope)
                        // is it a nested text inset?
                        case TEXT_CODE: {
                                InsetText const * itext = insit.inset->asInsetText();
-                               // Inset needs its own scope?
-                               bool newScope = itext->isMacroScope();
-
-                               // scope which ends just behind the inset
-                               DocIterator insetScope = it;
-                               ++insetScope.pos();
 
                                // 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();
                                break;
                        }
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_; }