[LyX/2.4.x] Fix spacing problems in previews with math macros (#13120)

Juergen Spitzmueller spitz at lyx.org
Thu Nov 7 17:34:43 UTC 2024


commit a8d90cde6f4521153c68214a791951df0cefee65
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Wed Nov 6 18:26:14 2024 +0100

    Fix spacing problems in previews with math macros (#13120)
    
    This occurs on the legacy path when no cropping tools are available.
    
    (cherry picked from commit 9ffacb341dd7f63e31782e8c8f81be2c2074dd08)
---
 src/mathed/InsetMathHull.cpp | 7 +++++--
 status.24x                   | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 1f6c456621..0864a21d4b 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -817,8 +817,11 @@ void InsetMathHull::usedMacros(MathData const & md, DocIterator const & pos,
 			if (data) {
 				odocstringstream macro_def;
 				data->write(macro_def, true);
-				macro_def << endl;
-				defs.insert(macro_def.str());
+				// Empty lines will generate full rows
+				// with legacy preview and tightpage (#13120).
+				// So remove all preceding and trailing line breaks
+				// and re-add one at the end of the snippet
+				defs.insert(trim(macro_def.str(), "\n") + "\n");
 				asArray(data->definition(), ar);
 			}
 			usedMacros(ar, pos, macros, defs);
diff --git a/status.24x b/status.24x
index 853ef361c2..2008eb8dec 100644
--- a/status.24x
+++ b/status.24x
@@ -72,6 +72,9 @@ What's new
 
 - Fix loading order of fancyhdr (bug 13118).
 
+- Fix spacing problems in previews with math macros under specific
+  circumstances (bug 13120).
+
 
 * USER INTERFACE
 


More information about the lyx-cvs mailing list