]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / lyxfind.C
index 128949e3ecbc6d12c7d5fbb65a37805f42bc5adb..e5d0f75afbc6eb18d592aeb27ad6b1153d604f2f 100644 (file)
@@ -43,7 +43,7 @@ SearchResult SearchBackward(BufferView *, LyXText * text, string const & str,
 int LyXReplace(BufferView * bv,
                string const & searchstr, string const & replacestr,
                bool forward, bool casesens, bool matchwrd, bool replaceall,
-              bool once)
+               bool once)
 {
        if (!bv->available() || bv->buffer()->isReadonly()) 
                return 0;
@@ -76,14 +76,23 @@ int LyXReplace(BufferView * bv,
        
        // if nothing selected or selection does not equal search string
        // search and select next occurance and return if no replaceall
-       if (searchstr!=text->selectionAsString(bv->buffer())) {
+       string str1;
+       string str2;
+       if (casesens) {
+               str1 = searchstr;
+               str2 = text->selectionAsString(bv->buffer(), false);
+       } else {
+               str1 = lowercase(searchstr);
+               str2 = lowercase(text->selectionAsString(bv->buffer(), false));
+       }
+       if (str1 != str2) {
                if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
                        !replaceall)
                {
                        return 0;
                }
        }
-   
+
        bool found = false;
        int replace_count = 0;
        do {
@@ -95,7 +104,7 @@ int LyXReplace(BufferView * bv,
                bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                ++replace_count;
                if (!once)
-                 found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
+                       found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
        } while (!once && replaceall && found);
    
        if (bv->focus())
@@ -106,7 +115,7 @@ int LyXReplace(BufferView * bv,
 
 bool LyXFind(BufferView * bv,
              string const & searchstr, bool forward,
-            bool frominset, bool casesens, bool matchwrd)
+             bool frominset, bool casesens, bool matchwrd)
 {
        if (!bv->available() || searchstr.empty())
                return false;
@@ -302,7 +311,9 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
        if (par) {
                text->setCursor(bv, par, pos);
                return SR_FOUND;
-       } else if (text->inset_owner) {
+       }
+#if 0
+       else if (text->inset_owner) {
                // test if we're inside an inset if yes unlock the inset
                // and recall us with the outside LyXText!
                bv->unlockInset((UpdatableInset *)text->inset_owner);
@@ -310,6 +321,7 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
                        return SearchBackward(bv, bv->getLyXText(), str, cs, mw);
                }
        }
+#endif
        return SR_NOT_FOUND;
 }