From: Richard Kimberly Heck Date: Fri, 6 Nov 2020 16:41:20 +0000 (-0500) Subject: The isMacroScope method is just !producesOutput (or should be). X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1c3a66b47778412f600d18ace51375482dd94df9;p=features.git The isMacroScope method is just !producesOutput (or should be). So remove that, and restructure the code a bit. --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index acda58f46f..44b3178bf4 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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; } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index a70ff27463..17e8007d39 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -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; diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h index 6106ce5a5c..27464855d6 100644 --- a/src/insets/InsetBranch.h +++ b/src/insets/InsetBranch.h @@ -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; } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index fa84c61c87..5717febf4f 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -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) diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index aeab8f038b..b698505680 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -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, diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index d571806ba6..cefd44cabf 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -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_; }