]> git.lyx.org Git - features.git/commitdiff
Remove indentation on screen after a plain separator inset
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 16 Mar 2023 09:25:00 +0000 (10:25 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 18 Mar 2023 18:47:42 +0000 (19:47 +0100)
Fixes bug #12700.

src/TextMetrics.cpp
src/insets/InsetSeparator.h

index 7acf5ffbbbb97a2f57f774611dbf6763655b0a0b..f4241181c295e15f440d78a48f05dbf6d7621d5f 100644 (file)
@@ -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);
index 0c12d95686f12d4563690de8c751d7168b426095..b824214ae7914e3e2e1b8fcfbab91d90cee39139 100644 (file)
@@ -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; }