Author: switt
Date: Thu May 19 21:11:01 2011
New Revision: 38790
URL: http://www.lyx.org/trac/changeset/38790
Log:
#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
Modified:
lyx-devel/branches/BRANCH_2_0_X/src/LyXAction.cpp
lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/Menus.cpp
lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.cpp
lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.h
lyx-devel/branches/BRANCH_2_0_X/status.20x
Modified: lyx-devel/branches/BRANCH_2_0_X/src/LyXAction.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/LyXAction.cpp Thu May 19 13:56:36
2011 (r38789)
+++ lyx-devel/branches/BRANCH_2_0_X/src/LyXAction.cpp Thu May 19 21:11:01
2011 (r38790)
@@ -863,7 +863,7 @@
* \li Params: <DATA>: data is of the form
"<replace> \n
<search> \n
- <casesensitive> <matchword> <all> <forward>"
+ <casesensitive> <matchword> <all> <forward> <findnext>"
* \li Origin: Andre, Jan 7 2004
* \endvar
*/
Modified: lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/Menus.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/Menus.cpp Thu May 19
13:56:36 2011 (r38789)
+++ lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/Menus.cpp Thu May 19
21:11:01 2011 (r38790)
@@ -788,8 +788,8 @@
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
Modified: lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.cpp Thu May 19 13:56:36
2011 (r38789)
+++ lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.cpp Thu May 19 21:11:01
2011 (r38790)
@@ -229,7 +229,7 @@
// whether anything at all was done.
pair<bool, int> 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 @@
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<bool, int>(true, 1);
}
@@ -300,7 +301,7 @@
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 @@
<< int(casesensitive) << ' '
<< int(matchword) << ' '
<< int(all) << ' '
- << int(forward);
+ << int(forward) << ' '
+ << int(findnext);
return ss.str();
}
@@ -343,7 +345,7 @@
// data is of the form
// "<search>
// <replace>
- // <casesensitive> <matchword> <all> <forward>"
+ // <casesensitive> <matchword> <all> <forward> <findnext>"
docstring search;
docstring rplc;
docstring howto = split(ev.argument(), rplc, '\n');
@@ -353,6 +355,7 @@
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 @@
update = replace_count > 0;
} else {
pair<bool, int> 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 @@
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))
Modified: lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.h
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.h Thu May 19 13:56:36
2011 (r38789)
+++ lyx-devel/branches/BRANCH_2_0_X/src/lyxfind.h Thu May 19 21:11:01
2011 (r38790)
@@ -48,7 +48,8 @@
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.
Modified: lyx-devel/branches/BRANCH_2_0_X/status.20x
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/status.20x Thu May 19 13:56:36 2011
(r38789)
+++ lyx-devel/branches/BRANCH_2_0_X/status.20x Thu May 19 21:11:01 2011
(r38790)
@@ -112,6 +112,8 @@
- 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