Patch #2027 2007-05-30 01:46

dmoore

Patch for bug 10992
Download
2027-Patch_for_bug.patch (2.6 KB)
Category
Application::Bugfix
Status
Accepted
Close date
2007-06-04 16:50
Assigned to
biplab
Index: src/sdk/replacedlg.cpp
===================================================================
--- src/sdk/replacedlg.cpp    (revision 4010)
+++ src/sdk/replacedlg.cpp    (working copy)
@@ -73,7 +73,7 @@
     XRCCTRL(*this, "rbDirection", wxRadioBox)->Enable(!XRCCTRL(*this, "chkRegEx1", wxCheckBox)->GetValue()); // if regex, only forward searches
     XRCCTRL(*this, "rbOrigin", wxRadioBox)->SetSelection(cfg->ReadInt(CONF_GROUP _T("/origin"), 0));
     XRCCTRL(*this, "rbScope1", wxRadioBox)->SetSelection(hasSelection);
-    XRCCTRL(*this, "rbScope1", wxRadioBox)->Enable(hasSelection);
+    //XRCCTRL(*this, "rbScope1", wxRadioBox)->Enable(hasSelection);
     // special key, uses same config for both find & replace options
     XRCCTRL(*this, "chkAutoWrapSearch", wxCheckBox)->SetValue(cfg->ReadBool(_T("/find_options/auto_wrap_search"), true));

Index: src/sdk/finddlg.cpp
===================================================================
--- src/sdk/finddlg.cpp    (revision 4010)
+++ src/sdk/finddlg.cpp    (working copy)
@@ -89,7 +89,7 @@
     XRCCTRL(*this, "rbDirection", wxRadioBox)->Enable(!XRCCTRL(*this, "chkRegEx1", wxCheckBox)->GetValue()); // if regex, only forward searches
     XRCCTRL(*this, "rbOrigin", wxRadioBox)->SetSelection(cfg->ReadInt(CONF_GROUP _T("/origin"), 0));
     XRCCTRL(*this, "rbScope1", wxRadioBox)->SetSelection(hasSelection);
-    XRCCTRL(*this, "rbScope1", wxRadioBox)->Enable(hasSelection);
+//    XRCCTRL(*this, "rbScope1", wxRadioBox)->Enable(hasSelection);

     // find in files options
     XRCCTRL(*this, "cmbFind2", wxComboBox)->SetValue(initial);
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 4010)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -1222,14 +1222,9 @@
         int wordEnd = control->WordEndPosition(control->GetCurrentPos(), true);
         wxString wordAtCursor = control->GetTextRange(wordStart, wordEnd);
         phraseAtCursor = control->GetSelectedText();
-        // if selected text is the last searched text, don't suggest "search in selection"
-        if ((m_LastFindReplaceData &&
-                !phraseAtCursor.IsEmpty() &&
-                phraseAtCursor == m_LastFindReplaceData->findText)
-                || phraseAtCursor == wordAtCursor)
-        {
+        // if selected text is part of a single line, don't suggest "search in selection"
+        if (control->LineFromPosition(control->GetSelectionStart())
+            == control->LineFromPosition(control->GetSelectionEnd()))
             hasSelection = false;
-        }

         if ( phraseAtCursor.IsEmpty())
             phraseAtCursor = wordAtCursor;
dmoore 2007-05-30 12:10

I realize I forgot to update the replace dialog as well...

dmoore 2007-05-30 14:54

updated patch (change to replace dialog as well)

dmoore 2007-05-30 15:41

another update. this one doesn't rely on line endings being \r and/or \n

pauliusz 2007-06-01 15:02

Similar to my patch

Bug #10992">http://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2010&group_id=5358

it was rejected by biplab, because he made patch for this bug by himself... and after some time he reverted it :)

dmoore 2007-06-01 15:16

I submitted this one because patch 2010 broke "uses selected text". this patch does not break this feature. it also gives you access to global scope irrespective of what has been selected.

biplab 2007-06-01 16:53

@pauliusz,

That time I found that the fix I prepared was good enough. But later when it broke other parts, I reverted it. I'm sorry as I didn't give any explanation on why your patch was rejected. I appreciate your hard work and I can understand your feeling when your patch was rejected without an explanation. :)

@dmoore

Give me couple of days to test it. I wrote in forum that it created a bug. Let me make sure that this patch is not the reason behind it.

pauliusz 2007-06-02 08:43

@biplab,

Don't worry about my feelings :) I know you are working very hard on CB. Also I think dmoore patch is better then mine (haven't tested, only my intuition).

biplab 2007-06-04 16:50

Patch applied. Thanks for the patch.