From dbcfbe5b76d4748a1d7013f32e8d2678ad9ae2ef 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 6ded8944c0..45a6f72507 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -1078,7 +1078,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(); @@ -1097,13 +1097,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 a4e975b8a1..d81d4a8aaf 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 af27be2b91..7883475aab 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