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
// 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()) {
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);
}
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'
<< int(casesensitive) << ' '
<< int(matchword) << ' '
<< int(all) << ' '
- << int(forward);
+ << int(forward) << ' '
+ << int(findnext);
return ss.str();
}
// 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');
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;
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;
}
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))