Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Replace bug fix
oBFusCATed:
Currently there is one very annoying bug in C::B.
Steps to reproduce:
1. Select something
2. Search replace
3. Type something for replace string
4. Click Replace
5. Click yes in the next dialog
The result is that the word after the selection is replace, even though the selection matches the search term.
This patch tries to fix this, any comments?
--- Code: ---diff --git a/src/sdk/editormanager.cpp b/src/sdk/editormanager.cpp
index 73e1956..28f6fec 100644
--- a/src/sdk/editormanager.cpp
+++ b/src/sdk/editormanager.cpp
@@ -1479,8 +1479,13 @@ void EditorManager::CalculateFindReplaceStartEnd(cbStyledTextCtrl* control, cbFi
// there can be a selection, the last found match)
if ((data->scope == 0) && data->NewSearch && (ssta != cpos || send != cpos))
{
- ssta = cpos;
- send = cpos;
+ // Don't do this in replace mode, because we want to start the replacement
+ // with the current selection, not the first match after the selection.
+ if (!replace)
+ {
+ ssta = cpos;
+ send = cpos;
+ }
}
@@ -1587,7 +1592,7 @@ int EditorManager::Replace(cbStyledTextCtrl* control, cbFindReplaceData* data)
}
control->BeginUndoAction(); // The undo is set at this point in case we need to convert the EOLs.
- CalculateFindReplaceStartEnd(control, data);
+ CalculateFindReplaceStartEnd(control, data, true);
if (data->matchWord)
flags |= wxSCI_FIND_WHOLEWORD;
--- End code ---
ollydbg:
Go ahead, I think this bug is quite annoying for a long time.
oBFusCATed:
There is another problem with this dialog.
Here it is:
1. Install MouseSap plugin
2. Open a source file
3. Select something
4. Press ctrl+f, ctrl+r
5. See that the string in the field "Text search for" is not selected
6. If you start to type you won't override it, but you start to append to it, which is very annoying.
This problem started some time ago and it was not present before.
It happens on both up-to-date gentoo and up-to-date centos5. I've not tried to reproduce it on windows.
I've tried to find why it happens. What I've found is that it happens because of this line:
MouseSap.cpp line 630
--- Code: --- gtk_clipboard_set_text(
gtk_clipboard_get(GDK_SELECTION_PRIMARY),
selectedText.mb_str(wxConvUTF8),
selectedText.Length() );
--- End code ---
If I comment it or remove the call to focus the text field the bug disappears.
Any ideas and comments?
thomas:
My 8541 build does not have this problem, or I'm too stupid to reproduce.
If I select something and then search/replace, it only ever replaces occurrences inside the selection, as I would expect.
Are you sure this is not some broken plugin that adds "extra smartness" and doesn't work?
oBFusCATed:
--- Quote from: thomas on June 10, 2013, 11:47:42 am ---If I select something and then search/replace, it only ever replaces occurrences inside the selection, as I would expect.
--- End quote ---
The idea is that you don't search inside the selection, but you select something (single word), fire up the replace dialog and don't change the search term.
It should match the selection and also the selection should be still active in the editor.
--- Quote from: thomas on June 10, 2013, 11:47:42 am ---Are you sure this is not some broken plugin that adds "extra smartness" and doesn't work?
--- End quote ---
Reproduces with just the core built from inside C::B.
Navigation
[0] Message Index
[#] Next page
Go to full version