[LyX/master] Fix pasting of crossrefs in math (#13290)

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

    Fix pasting of crossrefs in math (#13290)
---
 src/CutAndPaste.cpp          | 8 ++++++--
 src/CutAndPaste.h            | 6 ++----
 src/mathed/InsetMathGrid.cpp | 3 +--
 src/mathed/InsetMathNest.cpp | 3 +--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 167e321894..d5c36b9670 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 a0b36ab565..58c405eef6 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 834b5bfbc3..604919a6d1 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;
-- 
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.