]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Update toolbar and properly reset focus when find widget is closed (#12396)
[lyx.git] / src / Paragraph.cpp
index dc4be43703d70dc38177c24d17eccd1b5ee02dd7..6b1e118697cabbd6a2b099f8a5d11a4ac894fdfa 100644 (file)
@@ -2268,6 +2268,16 @@ bool Paragraph::isPassThru() const
        return inInset().isPassThru() || d->layout_->pass_thru;
 }
 
+
+bool Paragraph::isPartOfTextSequence() const
+{
+       for (pos_type i = 0; i < size(); ++i) {
+               if (!isInset(i) || getInset(i)->isPartOfTextSequence())
+                       return true;
+       }
+       return false;
+}
+
 namespace {
 
 // paragraphs inside floats need different alignment tags to avoid
@@ -2339,24 +2349,29 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
                        (layout_->toggle_indent != ITOGGLE_NEVER) :
                        (layout_->toggle_indent == ITOGGLE_ALWAYS);
 
-       // 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;
+       // Do not output \\noindent for paragraphs
+       // 1. that cannot have indentation or are indented always,
+       // 2. that are not part of the immediate text sequence (e.g., contain only floats),
+       // 3. that are PassThru,
+       // 4. or that are centered.
+       if (canindent && params_.noindent()
+           && owner_->isPartOfTextSequence()
+           && !layout_->pass_thru
+           && curAlign != LYX_ALIGN_CENTER) {
+               if (!owner_->empty()
+                   && (owner_->isInset(0)
+                       && owner_->getInset(0)->lyxCode() == VSPACE_CODE))
+                       // If the paragraph starts with a vspace, the \\noindent
+                       // needs to come after that (as it leaves vmode).
+                       // If the paragraph consists only of the vspace,
+                       // \\noindent is not needed at all.
+                       runparams.need_noindent = owner_->size() > 1;
+               else {
+                       os << "\\noindent" << termcmd;
+                       column += 10;
+               }
        }
 
        if (curAlign == layout_->align)