1

Resolved

Find and Replace dialog issue changing to replace tab

description

Hi,

I think this is not reported, at least I didn't found it...

I am using the default find and replace dialog and with the following steps I get an exception:
  • Insert text in the find combo box
  • Change to replace tab
  • Click on replace next
The exception occurs in FindReplaceDialog.cs, in the function AddReplacMru.
in line
cboReplace.SelectedIndex = 0;

As the combo has no entries it is not possible to set the selected item.
I solved it by checking the combo box entries.

Regards,
Sandra

comments

wrote Feb 18, 2014 at 6:39 PM

Associated with changeset 105287.

jacobslusser wrote Feb 18, 2014 at 6:41 PM

You're right. Good find! :)

The way I chose to fix this was to disable the find and replace buttons when their is no value in the Find field. This behavior is consistent with the Find/Replace dialog in Visual Studio.

This change has been made in the Releases\2.6 branch and will be included in a future release.

eried wrote Apr 14, 2014 at 4:38 PM

This bug is still present in the Branch.
cboReplace.SelectedIndex = 0; 
should be:
if(cboReplace.Items.Count > 0)
                cboReplace.SelectedIndex = 0;

pvanukoff wrote Oct 19, 2014 at 3:16 PM

Chiming in with eried, this bug is not resolved.

Steps to reproduce:
  1. Launch Find/Replace dialog.
  2. Switch to the Replace tab.
  3. Enter something in the "Find" box.
  4. Enter nothing in the "Replace" box (there also should be nothing in the dropdown).
  5. Click any of the Replace buttons.
The problem is, as eried wrote, that the code needs to make sure cboReplace actually has items in it before setting the SelectedIndex. I noticed there is an unapplied patch for this issue -- patch # 14614.

Thanks!

pvanukoff wrote Oct 19, 2014 at 3:55 PM

Ignore the above fixes ...

The best solution here is to just allow an empty string as a valid value for the "Replace" field. This would resolve the issue and also allow replacing text with empty strings (a common use case).

Thanks!