[LyX/2.5.x] Fix pasting from LaTeX with keepEmpty environment in first paragraph (#13295)

Juergen Spitzmueller <[email protected]> Thu, 23 Apr 2026 16:38:43 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit e0c1970713dcc25451ef8cb85d9de92aa6b99546
Author: Juergen Spitzmueller <[email protected]>
Date:   Wed Apr 8 19:12:13 2026 +0200

    Fix pasting from LaTeX with keepEmpty environment in first paragraph (#13295)
    
    (cherry picked from commit a2e701af72513a7b4dcf5c4e8d5f63523dbf5904)
---
 src/CutAndPaste.cpp | 2 +-
 status.25x          | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index 6a035a247b..dedd80daaa 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -1357,7 +1357,7 @@ bool pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs,
 				available = buffer.importString(names[i], text, errorList);
 				if (available)
 					available = !buffer.paragraphs().empty();
-				if (available && !buffer.paragraphs()[0].empty()) {
+				if (available && (!buffer.paragraphs()[0].empty() || buffer.paragraphs()[0].layout().keepempty)) {
 					// TeX2lyx (also used in the HTML chain) assumes English as document language
 					// if no language is explicitly set (as is the case here).
 					// We thus reset the temp buffer's language to the context language
diff --git a/status.25x b/status.25x
index 18675ff575..0176b9db82 100644
--- a/status.25x
+++ b/status.25x
@@ -52,7 +52,10 @@ What's new
 
 - Load externally referred buffers and initialize their labels.
 
-- Fix pasting of cross-references in math (bug 13290)
+- Fix pasting of cross-references in math (bug 13290).
+
+- Fix pasting from LaTeX with keepEmpty environment in first paragraph
+  (bug 13295).
 
 - Fix casing of strings in English localization (bug 13304).
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs