]> git.lyx.org Git - features.git/commitdiff
Account for changes in insets when checking changes in selection
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 6 Mar 2020 09:53:54 +0000 (10:53 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:53 +0000 (15:48 +0200)
This is not ideal, see FIXME.

Fixes #11774

src/Paragraph.cpp
src/Paragraph.h
src/Text3.cpp

index 710587bb578a4a736420b7eac727032dc30f7b76..27d1230f97d9f7e637f28113478f8e924e626484 100644 (file)
@@ -598,6 +598,24 @@ bool Paragraph::isChanged(pos_type start, pos_type end) const
        return d->changes_.isChanged(start, end);
 }
 
+// FIXME: Ideally the diverse isChanged() methods should account for that!
+bool Paragraph::hasChangedInsets(pos_type start, pos_type end) const
+{
+       LASSERT(start >= 0 && start <= size(), return false);
+       LASSERT(end > start && end <= size() + 1, return false);
+
+       InsetList::const_iterator icit = d->insetlist_.begin();
+       InsetList::const_iterator iend = d->insetlist_.end();
+       for (; icit != iend; ++icit) {
+               if (icit->pos < start)
+                       continue;
+               if (icit->pos >= end)
+                       break;
+               if (icit->inset && icit->inset->isChanged())
+                       return true;
+       }
+       return false;
+}
 
 bool Paragraph::isChanged() const
 {
index 297bff3847bcd7aa12d4c5ab8d27a8ae5d627a7a..d5c02e4053dc6290f9f445641f3702edda4104e3 100644 (file)
@@ -262,6 +262,8 @@ public:
        /// is there a change within the given range (does not
        /// check contained paragraphs)
        bool isChanged(pos_type start, pos_type end) const;
+       /// Are there insets containing changes in the range?
+       bool hasChangedInsets(pos_type start, pos_type end) const;
        /// is there an unchanged char at the given pos ?
        bool isChanged(pos_type pos) const;
        /// is there a change in the paragraph ?
index 1e0180cc2e726375487a1818373d1851e758dab1..81b01324ada93af26b28c9fb5e6dec79a0ada8da 100644 (file)
@@ -3364,6 +3364,10 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                                        enable = true;
                                        break;
                                }
+                               if (beg != end && it.paragraph().hasChangedInsets(beg, end)) {
+                                       enable = true;
+                                       break;
+                               }
                                if (in_last_par)
                                        break;
                        }