[LyX/master] Account for changes in insets when checking changes in selection
Juergen Spitzmueller
spitz at lyx.org
Fri Mar 6 09:35:25 UTC 2020
commit 228d738868991092c34d9924707594ede19c44cb
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Fri Mar 6 10:53:54 2020 +0100
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(+), 0 deletions(-)
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 710587b..27d1230 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 297bff3..d5c02e4 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 1e0180c..81b0132 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;
}
More information about the lyx-cvs
mailing list