[LyX/master] Paragraph: generalize hasChangedInsets into hasInsets(changed_only)

Pavel Sanda sanda at lyx.org
Fri Sep 4 19:48:24 UTC 2026


commit bec35f3fc50e33def89b721dffd2bae12a9e8750
Author: Pavel Sanda <sanda at lyx.org>
Date:   Wed Aug 26 23:36:49 2026 +0200

    Paragraph: generalize hasChangedInsets into hasInsets(changed_only)
    
    Add generic hasInsets, refactor hasChangedInsets for it.
    
    Assisted-by: Claude Fable 5
---
 src/Paragraph.cpp | 4 ++--
 src/Paragraph.h   | 7 ++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index cbb8c98377..d4fe200d46 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -639,7 +639,7 @@ bool Paragraph::isChanged(pos_type start, pos_type end) const
 }
 
 // FIXME: Ideally the diverse isChanged() methods should account for that!
-bool Paragraph::hasChangedInsets(pos_type start, pos_type end) const
+bool Paragraph::hasInsets(pos_type start, pos_type end, bool changed_only) const
 {
 	LASSERT(start >= 0 && start <= size(), return false);
 	LASSERT(end > start && end <= size() + 1, return false);
@@ -649,7 +649,7 @@ bool Paragraph::hasChangedInsets(pos_type start, pos_type end) const
 			continue;
 		if (icit.pos >= end)
 			break;
-		if (icit.inset && icit.inset->isChanged())
+		if (icit.inset && (!changed_only || icit.inset->isChanged()))
 			return true;
 	}
 	return false;
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 83cb848243..4f3b2d23ab 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -283,8 +283,13 @@ public:
 	/// is there a change within the given range (does not
 	/// check contained paragraphs)
 	bool isChanged(pos_type start, pos_type end) const;
+	/// Is there an inset in the range [start, end)? With \p changed_only,
+	/// count only insets that carry a tracked change.
+	bool hasInsets(pos_type start, pos_type end,
+		bool changed_only = false) const;
 	/// Are there insets containing changes in the range?
-	bool hasChangedInsets(pos_type start, pos_type end) const;
+	bool hasChangedInsets(pos_type start, pos_type end) const
+		{ return hasInsets(start, end, true); }
 	/// is there an unchanged char at the given pos ?
 	bool isChanged(pos_type pos) const;
 	/// is there a change in the paragraph ?


More information about the lyx-cvs mailing list