From 6e13892455ef9cb3b3e2dc6bca588e245ceb6c40 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 6 Mar 2020 10:53:54 +0100 Subject: [PATCH] Account for changes in insets when checking changes in selection This is not ideal, see FIXME. Fixes #11774 --- src/Paragraph.cpp | 18 ++++++++++++++++++ src/Paragraph.h | 2 ++ src/Text3.cpp | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 710587bb57..27d1230f97 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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 { diff --git a/src/Paragraph.h b/src/Paragraph.h index 297bff3847..d5c02e4053 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -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 ? diff --git a/src/Text3.cpp b/src/Text3.cpp index 1e0180cc2e..81b01324ad 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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; } -- 2.39.5