]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
FindAdv: Amend ec387b6d: Handle search for '{' and '}'
[lyx.git] / src / Paragraph.cpp
index 5930cb86a8dd57f6e3417b5dba96140d37656254..8a634a6b0c9d4fcbaf0293f90156e460988149ba 100644 (file)
@@ -5,7 +5,7 @@
  *
  * \author Asger Alstrup
  * \author Lars Gullik Bjønnes
- * \author Richard Heck (XHTML output)
+ * \author Richard Kimberly Heck (XHTML output)
  * \author Jean-Marc Lasgouttes
  * \author Angus Leeming
  * \author John Levon
@@ -1129,10 +1129,20 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
 {
        char_type const c = owner_->getUChar(bparams, runparams, i);
 
-       if (style.pass_thru || runparams.pass_thru
+       if (style.pass_thru || runparams.pass_thru || runparams.for_search
            || contains(style.pass_thru_chars, c)
            || contains(runparams.pass_thru_chars, c)) {
-               if (c != '\0') {
+               if (runparams.for_search) {
+                       if (c == '\\')
+                               os << "\\\\";
+                       else if (c == '{')
+                               os << "\\braceleft";
+                       else if (c == '}')
+                               os << "\\braceright";
+                       else if (c != '\0')
+                               os.put(c);
+               }
+               else if (c != '\0') {
                        Encoding const * const enc = runparams.encoding;
                        if (enc && !enc->encodable(c))
                                throw EncodingException(c);
@@ -2625,7 +2635,6 @@ void Paragraph::latex(BufferParams const & bparams,
                                os << "}";
                                alien_script.clear();
                        }
-                       bool needPar = false;
                        if (in_ct_deletion) {
                                // We have to close and then reopen \lyxdeleted,
                                // as strikeout needs to be on lowest level.
@@ -2636,6 +2645,7 @@ void Paragraph::latex(BufferParams const & bparams,
                                // Force language closing
                                current_font.setLanguage(basefont.language());
                        Font const nextfont = (i == body_pos-1) ? basefont : current_font;
+                       bool needPar = false;
                        column += running_font.latexWriteEndChanges(
                                    os, bparams, runparams, basefont,
                                    nextfont, needPar);
@@ -2703,8 +2713,8 @@ void Paragraph::latex(BufferParams const & bparams,
                                if (in_ct_deletion) {
                                        // We have to close and then reopen \lyxdeleted,
                                        // as strikeout needs to be on lowest level.
-                                       bool needPar = false;
                                        OutputParams rp = runparams;
+                                       bool needPar = false;
                                        column += running_font.latexWriteEndChanges(
                                                os, bparams, rp, basefont,
                                                basefont, needPar);
@@ -4386,24 +4396,40 @@ int Paragraph::find(docstring const & str, bool cs, bool mw,
        int i = 0;
        pos_type const parsize = d->text_.size();
        for (i = 0; i < strsize && pos < parsize; ++i, ++pos) {
+               // ignore deleted matter
+               if (!del && isDeleted(pos)) {
+                       if (pos == parsize - 1)
+                               break;
+                       pos++;
+                       --i;
+                       continue;
+               }
                // Ignore "invisible" letters such as ligature breaks
                // and hyphenation chars while searching
-               while (pos < parsize - 1 && isInset(pos)) {
+               bool nonmatch = false;
+               while (pos < parsize && isInset(pos)) {
                        Inset const * inset = getInset(pos);
-                       if (!inset->isLetter())
+                       if (!inset->isLetter() && !inset->isChar())
                                break;
                        odocstringstream os;
                        inset->toString(os);
-                       if (!os.str().empty())
-                               break;
+                       if (!os.str().empty()) {
+                               int const insetstringsize = os.str().length();
+                               for (int j = 0; j < insetstringsize && pos < parsize; ++i, ++j) {
+                                       if (str[i] != os.str()[j]) {
+                                               nonmatch = true;
+                                               break;
+                                       }
+                               }
+                       }
                        pos++;
                }
+               if (nonmatch || i == strsize)
+                       break;
                if (cs && str[i] != d->text_[pos])
                        break;
                if (!cs && uppercase(str[i]) != uppercase(d->text_[pos]))
                        break;
-               if (!del && isDeleted(pos))
-                       break;
        }
 
        if (i != strsize)