]> git.lyx.org Git - features.git/commitdiff
Fix searching bug #6139.
authorPavel Sanda <sanda@lyx.org>
Sat, 15 Aug 2009 15:35:14 +0000 (15:35 +0000)
committerPavel Sanda <sanda@lyx.org>
Sat, 15 Aug 2009 15:35:14 +0000 (15:35 +0000)
Patch by Tommaso.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31053 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/FindAndReplace.cpp
src/lyxfind.cpp
src/mathed/InsetMathHull.cpp

index 500514a5581c2ba6ebc99b2bd576ac63ff1cdbb3..9c8bf1e12eb18ca6b2ced48d92bc7d3a9d497668 100644 (file)
@@ -119,7 +119,6 @@ void FindAndReplaceWidget::findAndReplace(
                        searchString += it->stringify(pos_type(0), it->size(), AS_STR_INSETS, runparams);
                }
        }
-//     lyxerr << "Searching for '" << to_utf8(searchString) << "'" << std::endl;
        if (to_utf8(searchString).empty()) {
                buffer.message(_("Nothing to search"));
                return;
@@ -132,6 +131,16 @@ void FindAndReplaceWidget::findAndReplace(
        } else {
                replaceString = from_utf8(LYX_FR_NULL_STRING);
        }
+       LYXERR(Debug::DEBUG, "FindAndReplaceOptions: "
+              << "searchstring=" << searchString
+              << ", casesensitiv=" << casesensitive
+              << ", matchword=" << matchword
+              << ", backwards=" << backwards
+              << ", expandmacros=" << expandmacros
+              << ", ignoreformat=" << ignoreformat
+              << ", regexp=" << regexp
+              << ", replaceString" << replaceString
+              << std::endl);
        FindAndReplaceOptions opt(searchString, casesensitive, matchword, ! backwards,
                expandmacros, ignoreformat, regexp, replaceString);
        LYXERR(Debug::DEBUG, "Dispatching LFUN_WORD_FINDADV" << std::endl);
index 1002a01d09cf2f64a13ef9f6b373664b5eb28a71..750eb90d8aed82e19a98ac7deb4b54710f0d298e 100644 (file)
@@ -507,7 +507,7 @@ size_t find_matching_brace(string const & s, size_t pos)
        return s.size();
 }
 
-/// Within \regex{} apply get_regex_escapes(), while outside apply get_lyx_unescapes().
+/// Within \regexp{} apply get_regex_escapes(), while outside apply get_lyx_unescapes().
 string escape_for_regex(string s)
 {
        size_t pos = 0;
@@ -596,9 +596,6 @@ bool braces_match(string::const_iterator const & beg,
 }
 
 /** The class performing a match between a position in the document and the FindAdvOptions.
- **
- ** @todo The user-entered regexp expression(s) should be enclosed within something like \regexp{},
- **       to be written by a dedicated Inset, so to avoid escaping it in escape_for_regex().
  **/
 class MatchStringAdv {
 public:
@@ -768,8 +765,9 @@ string MatchStringAdv::normalize(docstring const & s) const
        while ((pos = t.find("\n")) != string::npos)
                t.replace(pos, 1, " ");
        // Remove stale empty \emph{}, \textbf{} and similar blocks from latexify
-       while (regex_replace(t, t, "\\\\[a-zA-Z_]+(\\{\\})+", ""))
-               ;
+       LYXERR(Debug::DEBUG, "Removing stale empty \emph{}, \textbf{} macros from: " << t);
+       while (regex_replace(t, t, "\\\\(emph|textbf)(\\{\\})+", ""))
+               LYXERR(Debug::DEBUG, "  further removing stale empty \emph{}, \textbf{} macros from: " << t);
        return t;
 }
 
index d22203816f4774bc9066a094473b5d7d2b1100cb..8b85e064fc75b1d9de6cf99e4dd85cdc184f04b8 100644 (file)
@@ -1671,8 +1671,11 @@ int InsetMathHull::plaintext(odocstream & os, OutputParams const & runparams) co
        } else {
                odocstringstream oss;
                WriteStream wi(oss, false, true, WriteStream::wsDefault, runparams.encoding);
-               wi << cell(0);
-
+               // Fix Bug #6139
+               if (type_ == hullRegexp)
+                       write(wi);
+               else
+                       wi << cell(0);
                docstring const str = oss.str();
                os << str;
                return str.size();