[LyX/master] Prevent unneeded (and wrong) \noindent
Juergen Spitzmueller
spitz at lyx.org
Sat Oct 30 11:57:21 UTC 2021
commit 045c25cf761dbc2d9efcab73af42a52496dcb075
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sat Oct 30 14:19:46 2021 +0200
Prevent unneeded (and wrong) \noindent
* When a paragraph is logically empty (only contains stuff which is not
part of the text sequence
* In centered paragraphs
---
src/Paragraph.cpp | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 09874a0..dc4be43 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2339,13 +2339,26 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
(layout_->toggle_indent != ITOGGLE_NEVER) :
(layout_->toggle_indent == ITOGGLE_ALWAYS);
- if (canindent && params_.noindent() && !layout_->pass_thru) {
- os << "\\noindent ";
- column += 10;
+ // Paragraphs that only contain insets which are not part of the text sequence
+ // (e.g., floats) should not get \\noindent (this would cause extra white space)
+ bool emptypar = true;
+ if (canindent) {
+ for (pos_type i = 0; i < owner_->size(); ++i) {
+ if (!owner_->isInset(i) || owner_->getInset(i)->isPartOfTextSequence()) {
+ emptypar = false;
+ break;
+ }
+ }
}
LyXAlignment const curAlign = params_.align();
+ if (canindent && !emptypar && params_.noindent()
+ && !layout_->pass_thru && curAlign != LYX_ALIGN_CENTER) {
+ os << "\\noindent ";
+ column += 10;
+ }
+
if (curAlign == layout_->align)
return column;
More information about the lyx-cvs
mailing list