[LyX/master] Do not copy deleted text to external clipboard

Juergen Spitzmueller spitz at lyx.org
Tue Dec 31 12:31:00 UTC 2019


commit 11c47ddfcfa8c83fd24b1e7e47279db32f1be9cd
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Dec 31 13:47:06 2019 +0100

    Do not copy deleted text to external clipboard
    
    Fixes #10416
---
 src/Cursor.cpp      |    8 ++++++--
 src/Cursor.h        |    3 ++-
 src/CutAndPaste.cpp |    6 +++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 431aa16..97d4972 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -347,7 +347,7 @@ docstring parbreak(CursorData const * cur)
 }
 
 
-docstring CursorData::selectionAsString(bool with_label) const
+docstring CursorData::selectionAsString(bool const with_label, bool const skipdelete) const
 {
 	if (!selection())
 		return docstring();
@@ -355,8 +355,12 @@ docstring CursorData::selectionAsString(bool with_label) const
 	if (inMathed())
 		return cap::grabSelection(*this);
 
-	int const label = with_label
+	int label = with_label
 		? AS_STR_LABEL | AS_STR_INSETS : AS_STR_INSETS;
+	if (skipdelete)
+		label = with_label
+				? AS_STR_LABEL | AS_STR_INSETS | AS_STR_SKIPDELETE
+				: AS_STR_INSETS | AS_STR_SKIPDELETE;
 
 	idx_type const startidx = selBegin().idx();
 	idx_type const endidx = selEnd().idx();
diff --git a/src/Cursor.h b/src/Cursor.h
index 4091790..ba353b6 100644
--- a/src/Cursor.h
+++ b/src/Cursor.h
@@ -154,7 +154,8 @@ public:
 	DocIterator selectionEnd() const;
 
 	///
-	docstring selectionAsString(bool with_label) const;
+	docstring selectionAsString(bool const with_label,
+				    bool const skipdelete = false) const;
 	/// get some interesting description of top position
 	void info(odocstream & os, bool devel_mode) const;
 	///
diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index d7a3a1f..4101933 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -950,7 +950,7 @@ void cutSelectionHelper(Cursor & cur, CutStack & cuts, bool realcut, bool putcli
 			// Even if there is no selection.
 			if (putclip)
 				putClipboard(cuts[0].first, cuts[0].second,
-				             cur.selectionAsString(true));
+				             cur.selectionAsString(true, true));
 		}
 
 		if (begpit != endpit)
@@ -1011,7 +1011,7 @@ void cutSelectionToTemp(Cursor & cur, bool realcut)
 
 void copySelection(Cursor const & cur)
 {
-	copySelection(cur, cur.selectionAsString(true));
+	copySelection(cur, cur.selectionAsString(true, true));
 }
 
 
@@ -1122,7 +1122,7 @@ void saveSelection(Cursor const & cur)
 	if (cur.selection()
 	    && cur.selBegin() == cur.bv().cursor().selBegin()
 	    && cur.selEnd() == cur.bv().cursor().selEnd()) {
-		LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true) << "'");
+		LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true, true) << "'");
 		copySelectionToStack(cur, selectionBuffer);
 	}
 }


More information about the lyx-cvs mailing list