]> git.lyx.org Git - features.git/commitdiff
In replaceSelectionWithString, do not select the new string
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Apr 2012 10:44:31 +0000 (12:44 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Apr 2012 10:44:31 +0000 (12:44 +0200)
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
src/CutAndPaste.h
src/lyxfind.cpp

index 2e0ae40f0b65e259e8c1324a085ff6b1b604737a..4914afb7cd16e1da36586022fd17b8c06df90245 100644 (file)
@@ -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());
 }
 
 
index abaad3728d7bb8f227abdb68150861a024be1931..c5c7aa4334c8841929ea2921b1e560cfcbf084d7 100644 (file)
@@ -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);
index f90e530d828b37ec61dc1e65c928fa6a620c132f..73f6469754fe43b3ca2e903e6c893fac52491622 100644 (file)
@@ -271,7 +271,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
        if (bv->buffer().isReadonly())
                return pair<bool, int>(false, 0);
 
-       cap::replaceSelectionWithString(cur, replacestr, forward);
+       cap::replaceSelectionWithString(cur, replacestr);
        if (forward) {
                cur.pos() += replacestr.length();
                LASSERT(cur.pos() <= cur.lastpos(), /* */);