From: Stephan Witt Date: Thu, 19 May 2011 19:11:01 +0000 (+0000) Subject: #7564 make the move forward to next match after text replacement optional and suppres... X-Git-Tag: 2.0.1~297 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4016d0b7a7c5ffca59d1ca514ddd83d710021a56;p=features.git #7564 make the move forward to next match after text replacement optional and suppress it when replace a word by selected suggestion; move the text cursor to the end of the word after replace of the misspelled with suggested text git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@38790 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 34693a4128..f9ee2f8730 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -863,7 +863,7 @@ void LyXAction::init() * \li Params: : data is of the form " \n \n - " + " * \li Origin: Andre, Jan 7 2004 * \endvar */ diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index c59c68999c..6af599be58 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -788,8 +788,8 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv) LYXERR(Debug::GUI, suggestion); MenuItem w(MenuItem::Command, toqstr(suggestion), FuncRequest(LFUN_WORD_REPLACE, - replace2string(suggestion,selection, - true, true, false, false))); + replace2string(suggestion, selection, + true, true, false, true, false))); if (i < m) add(w); else diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index a15ec587f9..158a2705ae 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -229,7 +229,7 @@ int replaceAll(BufferView * bv, // whether anything at all was done. pair replaceOne(BufferView * bv, docstring searchstr, docstring const & replacestr, bool case_sens, - bool whole, bool forward) + bool whole, bool forward, bool findnext) { Cursor & cur = bv->cursor(); if (!cur.selection()) { @@ -278,7 +278,8 @@ pair replaceOne(BufferView * bv, docstring searchstr, cur.pos() -= replacestr.length(); LASSERT(cur.pos() >= 0, /* */); } - findOne(bv, searchstr, case_sens, whole, forward, false); + if (findnext) + findOne(bv, searchstr, case_sens, whole, forward, false); return pair(true, 1); } @@ -300,7 +301,7 @@ docstring const find2string(docstring const & search, docstring const replace2string(docstring const & replace, docstring const & search, bool casesensitive, bool matchword, - bool all, bool forward) + bool all, bool forward, bool findnext) { odocstringstream ss; ss << replace << '\n' @@ -308,7 +309,8 @@ docstring const replace2string(docstring const & replace, << int(casesensitive) << ' ' << int(matchword) << ' ' << int(all) << ' ' - << int(forward); + << int(forward) << ' ' + << int(findnext); return ss.str(); } @@ -343,7 +345,7 @@ bool lyxreplace(BufferView * bv, // data is of the form // " // - // " + // " docstring search; docstring rplc; docstring howto = split(ev.argument(), rplc, '\n'); @@ -353,6 +355,7 @@ bool lyxreplace(BufferView * bv, bool matchword = parse_bool(howto); bool all = parse_bool(howto); bool forward = parse_bool(howto); + bool findnext = howto.empty() ? true : parse_bool(howto); int replace_count = 0; bool update = false; @@ -363,7 +366,7 @@ bool lyxreplace(BufferView * bv, update = replace_count > 0; } else { pair rv = - replaceOne(bv, search, rplc, casesensitive, matchword, forward); + replaceOne(bv, search, rplc, casesensitive, matchword, forward, findnext); update = rv.first; replace_count = rv.second; } @@ -383,7 +386,7 @@ bool lyxreplace(BufferView * bv, buf.message(str); } } - } else { + } else if (findnext) { // if we have deleted characters, we do not replace at all, but // rather search for the next occurence if (findOne(bv, search, casesensitive, matchword, forward)) diff --git a/src/lyxfind.h b/src/lyxfind.h index da632bf1a3..589a5d01d5 100644 --- a/src/lyxfind.h +++ b/src/lyxfind.h @@ -48,7 +48,8 @@ docstring const replace2string(docstring const & replace, bool casesensitive, bool matchword, bool all, - bool forward); + bool forward, + bool findnext = true); /** Parse the string encoding of the find request that is found in * \c ev.argument and act on it. diff --git a/status.20x b/status.20x index d753533184..f3f1e51037 100644 --- a/status.20x +++ b/status.20x @@ -112,6 +112,8 @@ What's new - Make size of characters in instant preview snippets independent of the LaTeX font size (bug 2200). +- Fix On-the-fly spellchecker jumps to next pattern match when replacing a + misspelled word with a suggested one from context menu (#7564). * DOCUMENTATION AND LOCALIZATION