]> git.lyx.org Git - features.git/commitdiff
Fixed bug that did not single replace words with casesensitive off sometimes.
authorJürgen Vigna <jug@sad.it>
Mon, 13 Aug 2001 10:09:50 +0000 (10:09 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 13 Aug 2001 10:09:50 +0000 (10:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2495 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxfind.C

index 2b6a4a6465e10955f61c146130977638a0bf097f..b52f7c6ca868e4a7e242cf78a17122016cb83c61 100644 (file)
@@ -1,3 +1,8 @@
+2001-08-13  Juergen Vigna  <jug@sad.it>
+
+       * lyxfind.C (LyXReplace): fixed not single-replacing characters with
+       casesensitive off.
+
 2001-08-11  Dekel Tsur  <dekelts@tau.ac.il>
 
        * Many files: Remove inherit_language, and add latex_language
index 128949e3ecbc6d12c7d5fbb65a37805f42bc5adb..34d1bfaebe14352a6c6b90958f60285307b42e11 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());
+       } else {
+               str1 = lowercase(searchstr);
+               str2 = lowercase(text->selectionAsString(bv->buffer()));
+       }
+       if (str1 != str2) {
                if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
                        !replaceall)
                {
                        return 0;
                }
        }
-   
+
        bool found = false;
        int replace_count = 0;
        do {
@@ -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;