]> git.lyx.org Git - features.git/commitdiff
Move updateMacros code to Paragraph class.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 13 Nov 2020 00:26:44 +0000 (19:26 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 13 Nov 2020 00:27:28 +0000 (19:27 -0500)
My dream is that this will eventually allow us to run updateMacros
only on a Paragraph when, say, a character is entered.

src/Paragraph.cpp
src/Paragraph.h
src/insets/InsetText.cpp

index c668f3b686734b8c267a6a6e6a8bbce5035e6c67..8a97209ea9f3563e48063e1a61c15f87ddc5a3ca 100644 (file)
@@ -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();
index 4812684c3de1788be93ac205ca954ee73c4a2f95..24bdbc87024be7425940c16f4da13b1cc1cde637 100644 (file)
@@ -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.
index ee04ee330f7a3eb0e4cf19fca20f1481f3f66424..942ef77db80c59eaf38c9069c53bb7a66cae9469 100644 (file)
@@ -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;