]> git.lyx.org Git - features.git/commitdiff
Fix bug #8238: correct the forward argument of replace2string() in on_replacePB_click...
authorStephan Witt <switt@lyx.org>
Thu, 26 Jul 2012 22:34:17 +0000 (00:34 +0200)
committerStephan Witt <switt@lyx.org>
Wed, 22 Aug 2012 16:07:58 +0000 (18:07 +0200)
(cherry picked from commit 44b327800666f30d2713c6c9e26f275aadfa4b9c)
Fix the wrong cursor move when forward flag is false:
The forward flag is used to place the cursor behind the replaced text if it's true.
But it's not correct to move the cursor if it's false. The cursor is in front of the
replacement already after the replaceSelectionWithString() was done.
(cherry picked from commit 430cf3ee5ef125b8bc610300afca58437b734306)

src/frontends/qt4/GuiSpellchecker.cpp
src/frontends/qt4/Menus.cpp
src/lyxfind.cpp
status.20x

index da8cca1ad3b4e55adb6c0cd9730a773167e63abf..5dbdbbb0b048affb80667b06c13a961967a5d438 100644 (file)
@@ -315,8 +315,13 @@ void SpellcheckerWidget::on_replacePB_clicked()
                return;
        docstring const textfield = qstring_to_ucs4(d->ui.wordED->text());
        docstring const replacement = qstring_to_ucs4(d->ui.replaceCO->currentText());
-       docstring const datastring = replace2string(replacement, textfield,
-               true, true, false, false);
+       docstring const datastring = 
+               replace2string(replacement, textfield,
+                       true,   // case sensitive
+                       true,   // match word
+                       false,  // all words
+                       true,   // forward
+                       false); // find next
 
        LYXERR(Debug::GUI, "Replace (" << replacement << ")");
        dispatch(FuncRequest(LFUN_WORD_REPLACE, datastring));
@@ -332,8 +337,13 @@ void SpellcheckerWidget::on_replaceAllPB_clicked()
                return;
        docstring const textfield = qstring_to_ucs4(d->ui.wordED->text());
        docstring const replacement = qstring_to_ucs4(d->ui.replaceCO->currentText());
-       docstring const datastring = replace2string(replacement, textfield,
-               true, true, true, true);
+       docstring const datastring =
+               replace2string(replacement, textfield,
+                       true,   // case sensitive
+                       true,   // match word
+                       true,   // all words
+                       true,   // forward
+                       false); // find next
 
        LYXERR(Debug::GUI, "Replace all (" << replacement << ")");
        dispatch(FuncRequest(LFUN_WORD_REPLACE, datastring));
index d0f2e4586d3715ed778e0a70ef02f5d9fbdf271a..367f14b120959f9a32a3b2cd383d6e32e7370495 100644 (file)
@@ -783,7 +783,11 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
                                        MenuItem w(MenuItem::Command, toqstr(suggestion),
                                                FuncRequest(LFUN_WORD_REPLACE, 
                                                        replace2string(suggestion, selection,
-                                                               true, true, false, true, false)));
+                                                               true,     // case sensitive
+                                                               true,     // match word
+                                                               false,    // all words
+                                                               true,     // forward
+                                                               false))); // find next
                                        if (i < m)
                                                add(w);
                                        else
index 7883475aab7f65915fa2f7f20be9c3fcb4f0208d..f2c941bcabc024205e8c90d8ab5f5543b323fb93 100644 (file)
@@ -275,9 +275,6 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
        if (forward) {
                cur.pos() += replacestr.length();
                LASSERT(cur.pos() <= cur.lastpos(), /* */);
-       } else {
-               cur.pos() -= replacestr.length();
-               LASSERT(cur.pos() >= 0, /* */);
        }
        if (findnext)
                findOne(bv, searchstr, case_sens, whole, forward, false);
index b4efefbe5fe2476c479ec81ec912cc58855199ae..8c492b4b45e49e8ea24abe9284d0c814f6956a44 100644 (file)
@@ -138,6 +138,8 @@ What's new
 - When using a non-default language for the GUI, do not change locale
   settings of child proceses (bug 7741).
 
+- Fix crash in text replacement with spell checker (bug 8238).
+
 
 * DOCUMENTATION AND LOCALIZATION