[LyX/master] Remove indentation on screen after a plain separator inset

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sat Mar 18 18:38:29 UTC 2023


commit f24bb4a91980a17c00c12ec0bbb457e0f182215f
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Thu Mar 16 10:25:00 2023 +0100

    Remove indentation on screen after a plain separator inset
    
    Fixes bug #12700.
---
 src/TextMetrics.cpp         |   16 ++++++++++++++--
 src/insets/InsetSeparator.h |    2 ++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 7acf5ff..f424118 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -35,6 +35,7 @@
 #include "TextClass.h"
 #include "VSpace.h"
 
+#include "insets/InsetSeparator.h"
 #include "insets/InsetText.h"
 
 #include "mathed/MacroTable.h"
@@ -1792,11 +1793,13 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
 		}
 	}
 
-	// This happens after sections or environments in standard classes.
-	// We have to check the previous layout at same depth.
+	// Check for reasons to remove indentation.
+	// First, at document level.
 	if (buffer.params().paragraph_separation ==
 			BufferParams::ParagraphSkipSeparation)
 		parindent.erase();
+	// This happens after sections or environments in standard classes.
+	// We have to check the previous layout at same depth.
 	else if (pit > 0 && pars[pit - 1].getDepth() >= par.getDepth()) {
 		pit_type prev = text_->depthHook(pit, par.getDepth());
 		if (par.layout() == pars[prev].layout()) {
@@ -1806,6 +1809,15 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
 		} else if (pars[prev].layout().nextnoindent)
 			parindent.erase();
 	}
+	// The previous paragraph may have ended with a separator inset.
+	if (pit > 0) {
+		Paragraph const & ppar = pars[pit - 1];
+		if (ppar.size() > 0) {
+			auto * in = dynamic_cast<InsetSeparator const *>(ppar.getInset(ppar.size() - 1));
+			if (in != nullptr && in->nextnoindent())
+				parindent.erase();
+		}
+	}
 
 	FontInfo const labelfont = text_->labelFont(par);
 	FontMetrics const & lfm = theFontMetrics(labelfont);
diff --git a/src/insets/InsetSeparator.h b/src/insets/InsetSeparator.h
index 0c12d95..b824214 100644
--- a/src/insets/InsetSeparator.h
+++ b/src/insets/InsetSeparator.h
@@ -66,6 +66,8 @@ public:
 	}
 	///
 	int rowFlags() const override { return BreakAfter | Flush; }
+	///
+	bool nextnoindent() const { return params_.kind == InsetSeparatorParams::PLAIN; }
 private:
 	///
 	InsetCode lyxCode() const override { return SEPARATOR_CODE; }


More information about the lyx-cvs mailing list