From 0e0c5c5d4c4109981e1ef4b3105c37bc1a97f17c Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Fri, 6 Nov 2020 11:41:20 -0500 Subject: [PATCH] The isMacroScope method is just !producesOutput (or should be). So remove that, and restructure the code a bit. --- src/Buffer.cpp | 23 ++++++++++++----------- src/insets/InsetBranch.cpp | 7 ------- src/insets/InsetBranch.h | 2 -- src/insets/InsetNote.cpp | 10 ---------- src/insets/InsetNote.h | 2 -- src/insets/InsetText.h | 2 -- 6 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 23f6315f5f..9562cb8c72 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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; } 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_; } -- 2.39.5