X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfind.cpp;h=73f6469754fe43b3ca2e903e6c893fac52491622;hb=837869452ad8d917615aa4bca77402dc49ba094e;hp=75fa19e46ec6b1483d78096e370b4058dd8e399d;hpb=144a69f4ebd86cad41fe975659c88ded584b4277;p=lyx.git diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 75fa19e46e..73f6469754 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -271,7 +271,7 @@ pair replaceOne(BufferView * bv, docstring searchstr, if (bv->buffer().isReadonly()) return pair(false, 0); - cap::replaceSelectionWithString(cur, replacestr, forward); + cap::replaceSelectionWithString(cur, replacestr); if (forward) { cur.pos() += replacestr.length(); LASSERT(cur.pos() <= cur.lastpos(), /* */); @@ -565,30 +565,6 @@ string apply_escapes(string s, Escapes const & escape_map) return s; } -#if 0 -// This is not used any longer, but I do not know if we want to delete -// it, since it seems like maybe it might be needed again. -/** Return the position of the closing brace matching the open one at s[pos], - ** or s.size() if not found. - **/ -static size_t find_matching_brace(string const & s, size_t pos) -{ - LASSERT(s[pos] == '{', /* */); - int open_braces = 1; - for (++pos; pos < s.size(); ++pos) { - if (s[pos] == '\\') - ++pos; - else if (s[pos] == '{') - ++open_braces; - else if (s[pos] == '}') { - --open_braces; - if (open_braces == 0) - return pos; - } - } - return s.size(); -} -#endif /// Within \regexp{} apply get_lyx_unescapes() only (i.e., preserve regexp semantics of the string), /// while outside apply get_lyx_unescapes()+get_regexp_escapes(). @@ -611,7 +587,8 @@ string escape_for_regex(string s, bool match_latex) LYXERR(Debug::FIND, "new_pos: " << new_pos); if (new_pos == s.size()) break; - size_t end_pos = s.find("\\endregexp{}}", new_pos + 8); // find_matching_brace(s, new_pos + 7); + // Might fail if \\endregexp{} is preceeded by unexpected stuff (weird escapes) + size_t end_pos = s.find("\\endregexp{}}", new_pos + 8); LYXERR(Debug::FIND, "end_pos: " << end_pos); t = s.substr(new_pos + 8, end_pos - (new_pos + 8)); LYXERR(Debug::FIND, "t in regexp : " << t); @@ -1156,12 +1133,12 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match) { if (!cur) return 0; - while (cur) { + while (!theApp()->longOperationCancelled() && cur) { LYXERR(Debug::FIND, "findForwardAdv() cur: " << cur); int match_len = match(cur, -1, false); LYXERR(Debug::FIND, "match_len: " << match_len); if (match_len) { - for (; cur; cur.forwardPos()) { + for (; !theApp()->longOperationCancelled() && cur; cur.forwardPos()) { LYXERR(Debug::FIND, "Advancing cur: " << cur); int match_len = match(cur); LYXERR(Debug::FIND, "match_len: " << match_len); @@ -1258,7 +1235,7 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) { else cur.backwardPos(); pit_changed = true; - } while (true); + } while (!theApp()->longOperationCancelled()); return 0; } @@ -1371,7 +1348,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M } } cap::cutSelection(cur, false, false); - if (!cur.inMathed()) { + if (cur.inTexted()) { repl_buffer.changeLanguage( repl_buffer.language(), cur.getFont().language()); @@ -1382,7 +1359,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M bv->buffer().errorList("Paste")); LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl); sel_len = repl_buffer.paragraphs().begin()->size(); - } else { + } else if (cur.inMathed()) { TexRow texrow; odocstringstream ods; otexstream os(ods, texrow);