[LyX/2.5.x] Fix pasting of crossrefs in math (#13290)

Juergen Spitzmueller <[email protected]>
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit f58a71a1279dc2c0c47093bc33bb4141874c48bb
Author: Juergen Spitzmueller <[email protected]>
Date:   Tue Mar 31 10:13:52 2026 +0200

    Fix pasting of crossrefs in math (#13290)
    
    (cherry picked from commit c930e4605133a746fba2b9ac21cd2d26f26ddb89)
---
 src/CutAndPaste.cpp          | 8 ++++++--
 src/CutAndPaste.h            | 6 ++----
 src/mathed/InsetMathGrid.cpp | 3 +--
 src/mathed/InsetMathNest.cpp | 3 +--
 status.25x                   | 4 +++-
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 1349acec36..6a035a247b 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -1226,13 +1226,13 @@ void clearCutStack()
 }
 
 
-docstring selection(size_t sel_index, DocInfoPair docinfo, bool for_math)
+docstring selection(size_t sel_index, BufferParams & bp, bool for_math)
 {
 	if (sel_index >= theCuts.size())
 		return docstring();
 
 	unique_ptr<Buffer> buffer(copyToTempBuffer(theCuts[sel_index].first,
-	                                           docinfo.first));
+						   bp.documentClassPtr()));
 	if (!buffer)
 		return docstring();
 
@@ -1240,6 +1240,10 @@ docstring selection(size_t sel_index, DocInfoPair docinfo, bool for_math)
 	if (for_math)
 		options |= AS_STR_MATHED;
 
+	// This is needed for proper xrefs handling in math
+	// LaTeX output depends on the setting
+	buffer->params().xref_package = bp.xref_package;
+
 	return buffer->paragraphs().back().asString(options);
 }
 
diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h
index edea773321..e011e03466 100644
--- a/src/CutAndPaste.h
+++ b/src/CutAndPaste.h
@@ -15,7 +15,7 @@
 #define CUTANDPASTE_H
 
 #include "Author.h"
-#include "DocumentClassPtr.h"
+#include "BufferParams.h"
 
 #include "support/types.h"
 
@@ -41,13 +41,11 @@ namespace cap {
 std::vector<docstring> availableSelections(Buffer const *);
 /// Get the number of available elements in the cut buffer.
 size_type numberOfSelections();
-///
-typedef std::pair<DocumentClassConstPtr, AuthorList > DocInfoPair;
 /**
  * Get the sel_index-th element of the cut buffer in plain text format
  * or, if \param for_math is true, in a format suitable for mathed.
  */
-docstring selection(size_t sel_index, DocInfoPair docinfo, bool for_math = false);
+docstring selection(size_t sel_index, BufferParams & bp, bool for_math = false);
 
 /**
  * Replace using the font of the first selected character and select
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index ce537667e0..9d29246d2f 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1577,8 +1577,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 			idocstringstream is(cmd.argument());
 			int n = 0;
 			is >> n;
-			topaste = cap::selection(n, make_pair(buffer().params().documentClassPtr(),
-							      buffer().params().authors()), true);
+			topaste = cap::selection(n, buffer().params(), true);
 		}
 		InsetMathGrid grid(buffer_, 1, 1);
 		if (!topaste.empty())
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index b628cb2ac9..2790b58719 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -845,8 +845,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 			size_t n = 0;
 			idocstringstream is(cmd.argument());
 			is >> n;
-			topaste = cap::selection(n, make_pair(buffer().params().documentClassPtr(),
-							      buffer().params().authors()));
+			topaste = cap::selection(n, buffer().params());
 		}
 		InsetMath const * im = cur.inset().asInsetMath();
 		InsetMathMacro const * macro = im ? im->asMacroInset() : nullptr;
diff --git a/status.25x b/status.25x
index 602b875b11..de3cea4f03 100644
--- a/status.25x
+++ b/status.25x
@@ -51,7 +51,9 @@ What's new
 
 - Load externally referred buffers and initialize their labels.
 
-- Fix casing of strings in English localization (13304).
+- Fix pasting of cross-references in math (bug 13290)
+
+- Fix casing of strings in English localization (bug 13304).
 
 
 * INTERNALS
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.