From: Richard Kimberly Heck Date: Fri, 13 Nov 2020 00:26:44 +0000 (-0500) Subject: Move updateMacros code to Paragraph class. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f0feeeee51ed7d1e609699c6d568a892e2c69030;p=features.git Move updateMacros code to Paragraph class. My dream is that this will eventually allow us to run updateMacros only on a Paragraph when, say, a character is entered. --- diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index c668f3b686..8a97209ea9 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -4553,6 +4553,21 @@ void Paragraph::updateWords() } +void Paragraph::updateMacros(DocIterator const & us, DocIterator const & scope) +{ + // We expect a DocIterator pointing at the beginning of this paragraph. + LBUFERR(&us.paragraph() == this && us.pos() == 0); + DocIterator it = us; + // iterate over the insets of the current paragraph + for (auto const & insit : insetList()) { + it.pos() = insit.pos; + it.push_back(CursorSlice(*insit.inset)); + insit.inset->updateMacros(it, scope); + it.pop_back(); + } +} + + void Paragraph::Private::appendSkipPosition(SkipPositions & skips, pos_type const pos) const { SkipPositionsIterator begin = skips.begin(); diff --git a/src/Paragraph.h b/src/Paragraph.h index 4812684c3d..24bdbc8702 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -476,6 +476,8 @@ public: word_location const loc, bool const ignore_deleted = false) const; /// void updateWords(); + /// + void updateMacros(DocIterator const & us, DocIterator const & scope); /// Spellcheck word at position \p from and fill in found misspelled word /// and \p suggestions if \p do_suggestion is true. diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index ee04ee330f..942ef77db8 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -925,14 +925,7 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) pit_type const lastpit = it.lastpit(); // look for macros in each paragraph while (it.pit() <= lastpit) { - Paragraph & par = it.paragraph(); - // iterate over the insets of the current paragraph - for (auto const & insit : par.insetList()) { - it.pos() = insit.pos; - it.push_back(CursorSlice(*insit.inset)); - insit.inset->updateMacros(it, ourscope); - it.pop_back(); - } + it.paragraph().updateMacros(it, ourscope); // next paragraph it.pit()++; it.pos() = 0;