[LyX/master] Fix previews in yellow notes and disabled branches
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Tue Dec 19 15:32:49 UTC 2023
commit 2d5fa181a1b187e47dae66b924a7eaf83b8fde72
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Tue Dec 19 17:45:00 2023 +0100
Fix previews in yellow notes and disabled branches
While it is not necessary to run validate() on insets that do not
produce output (yellow notes and disabled branches), it has to be done
for previewing, since a construct inside the inset may require some
support.
This is done in two steps:
1. in PreviewLoader::dumpPreamble, indicate that a preview is being
prepared. It is not clear why the `for_preview' boolean was not set
before.
2. in Inset(Branch|Note)::validate, always call the parent's validate
method when previewing.
It should have been possible to move the code from 2. to
InsetText::validate, but the weird code in handling
InsetNoteParams::Comment in html makes it difficult.
---
src/graphics/PreviewLoader.cpp | 1 +
src/insets/InsetBranch.cpp | 4 +++-
src/insets/InsetNote.cpp | 3 +++
3 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index 198d6d9..a350a49 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -809,6 +809,7 @@ void PreviewLoader::Impl::dumpPreamble(otexstream & os, Flavor flavor) const
runparams.moving_arg = true;
runparams.free_spacing = true;
runparams.is_child = buffer_.parent();
+ runparams.for_preview = true;
buffer_.writeLaTeXSource(os, buffer_.filePath(), runparams, Buffer::OnlyPreamble);
// FIXME! This is a HACK! The proper fix is to control the 'true'
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 7a97e2c..229e1bc 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -22,6 +22,7 @@
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "Inset.h"
+#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "LyX.h"
#include "output_docbook.h"
@@ -340,7 +341,8 @@ void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
void InsetBranch::validate(LaTeXFeatures & features) const
{
- if (producesOutput())
+ // Showing previews in a disabled branch may require stuff
+ if (producesOutput() || features.runparams().for_preview)
InsetCollapsible::validate(features);
}
diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp
index a7a0dc1..b12b755 100644
--- a/src/insets/InsetNote.cpp
+++ b/src/insets/InsetNote.cpp
@@ -334,6 +334,9 @@ void InsetNote::validate(LaTeXFeatures & features) const
InsetCollapsible::validate(features);
break;
case InsetNoteParams::Note:
+ // Showing previews in this inset may require stuff
+ if (features.runparams().for_preview)
+ InsetCollapsible::validate(features);
break;
}
}
More information about the lyx-cvs
mailing list