From a117a51226537d202ee264fedc125de9b8c957b1 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 18 Apr 2012 12:44:31 +0200 Subject: [PATCH] In replaceSelectionWithString, do not select the new string This is a patch from Scott Kostyshak. The problem it solves is as follows: 1. enable continuous spell check. 2. type a misspelled word and press space so that it has a wavy red underline. 3. right-click and choose a suggested replacement word. 4. press the backspace button. Result: nothing happens. If you press the backspace button again, then it works as normal. The selection code was added for the benefit of the spellchecker, but the code has been rewritten since then. --- src/CutAndPaste.cpp | 9 +-------- src/CutAndPaste.h | 7 ++----- src/lyxfind.cpp | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 2e0ae40f0b..4914afb7cd 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -1111,7 +1111,7 @@ void pasteSelection(Cursor & cur, ErrorList & errorList) } -void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwards) +void replaceSelectionWithString(Cursor & cur, docstring const & str) { cur.recordUndo(); DocIterator selbeg = cur.selectionBegin(); @@ -1130,13 +1130,6 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa // Cut the selection cutSelection(cur, true, false); - - // select the replacement - if (backwards) { - selbeg.pos() += str.length(); - cur.setSelection(selbeg, -int(str.length())); - } else - cur.setSelection(selbeg, str.length()); } diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index abaad3728d..c5c7aa4334 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -41,12 +41,9 @@ docstring selection(size_t sel_index); /** * Replace using the font of the first selected character and select - * the new string. When \c backwards == false, set anchor before - * cursor; otherwise set cursor before anchor. - * Does handle undo. + * the new string. Does handle undo. */ -void replaceSelectionWithString(Cursor & cur, docstring const & str, - bool backwards); +void replaceSelectionWithString(Cursor & cur, docstring const & str); /// If a selection exists, delete it without pushing it to the cut buffer. /// Does handle undo. void replaceSelection(Cursor & cur); diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index f90e530d82..73f6469754 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -271,7 +271,7 @@ pair replaceOne(BufferView * bv, docstring searchstr, if (bv->buffer().isReadonly()) return pair(false, 0); - cap::replaceSelectionWithString(cur, replacestr, forward); + cap::replaceSelectionWithString(cur, replacestr); if (forward) { cur.pos() += replacestr.length(); LASSERT(cur.pos() <= cur.lastpos(), /* */); -- 2.39.5