From aa2f409d871d36dc0e1c038aba900d06963d3459 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Wed, 25 Apr 2018 21:48:25 -0400 Subject: [PATCH] Restore implicit word selection for inset insertion. Modifies 83356ab9. --- src/CutAndPaste.cpp | 6 ++++++ src/CutAndPaste.h | 2 ++ src/Text3.cpp | 14 +++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index e27de0d18b..9088f6b6cc 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -1070,6 +1070,12 @@ void copySelectionToStack() } +void copySelectionToTemp(Cursor & cur) +{ + copySelectionToStack(cur, tempCut); +} + + void copySelection(Cursor const & cur, docstring const & plaintext) { // In tablemode, because copy and paste actually use special table stack diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 66df6b5904..d1d48d01d1 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -65,6 +65,8 @@ void cutSelectionToTemp(Cursor & cur, bool doclear = true, bool realcut = true); /// Push the current selection to the cut buffer and the system clipboard. void copySelection(Cursor const & cur); +/// Like copySelection, but only put to temporary cut buffer +void copySelectionToTemp(Cursor & cur); /// void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext); /** diff --git a/src/Text3.cpp b/src/Text3.cpp index fef9691f72..22f827e089 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -89,6 +89,7 @@ using namespace lyx::support; namespace lyx { using cap::copySelection; +using cap::copySelectionToTemp; using cap::cutSelection; using cap::cutSelectionToTemp; using cap::pasteFromStack; @@ -288,9 +289,16 @@ static bool doInsertInset(Cursor & cur, Text * text, bool gotsel = false; if (cur.selection()) { - cutSelectionToTemp(cur, false, pastesel); - cur.clearSelection(); - gotsel = true; + if (cmd.action() == LFUN_INDEX_INSERT) + copySelectionToTemp(cur); + else + cutSelectionToTemp(cur, false, pastesel); + cur.clearSelection(); + gotsel = true; + } else if (cmd.action() == LFUN_INDEX_INSERT) { + gotsel = text->selectWordWhenUnderCursor(cur, WHOLE_WORD); + copySelectionToTemp(cur); + cur.clearSelection(); } text->insertInset(cur, inset); -- 2.39.5