]> git.lyx.org Git - features.git/commitdiff
Do not copy deleted text to external clipboard
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 31 Dec 2019 12:47:06 +0000 (13:47 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:49 +0000 (15:48 +0200)
Fixes #10416

src/Cursor.cpp
src/Cursor.h
src/CutAndPaste.cpp

index 431aa16c5aafc9ccba35873d970ffd6637b102f1..97d497209e9d8839db17bc5e08dd5a4336975a22 100644 (file)
@@ -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();
index 4091790603d8b325e05310503b6c7bf7b98a7f54..ba353b6cb8ad247d14fb52004d7d74ad6d45498b 100644 (file)
@@ -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;
        ///
index d7a3a1fd3612929f646001f66a3e4857d3e9692d..41019338514297097ad2580f0fa325774981cf3c 100644 (file)
@@ -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);
        }
 }