@@ -32,45 +32,27 @@ public FormSearch()
3232 this . buttonReplace . Click += new EventHandler ( buttonReplace_Click ) ;
3333 this . buttonReplaceAll . Click += new EventHandler ( buttonReplaceAll_Click ) ;
3434 this . comboBoxFind . KeyDown += new KeyEventHandler ( comboBoxFind_KeyDown ) ;
35- this . comboBoxFind . LostFocus += new EventHandler ( comboBoxFind_LostFocus ) ;
3635
3736 this . comboBoxFilter . Items . AddRange ( new object [ ] { SearchFilter . Everything , SearchFilter . Names , SearchFilter . Text , SearchFilter . Comments } ) ;
3837 this . comboBoxFilter . SelectedItem = this . _filter ;
3938 this . comboBoxFilter . SelectedValueChanged += new EventHandler ( comboBoxFilter_SelectedValueChanged ) ;
4039 this . _tnav = new TabNavigator ( this ) ;
4140
4241 _recentFindStrings = new MostRecentlyUsed ( ) ;
43- _recentFindStrings . RecentItemSelected += OnRecentFindSelected ;
4442 _recentFindCombo = new RecentlyUsedComboBox ( _recentFindStrings , this . comboBoxFind ) ;
4543 _recentFindCombo . SelectFirstItemByDefault = false ;
4644
4745 _recentReplaceStrings = new MostRecentlyUsed ( ) ;
48- _recentReplaceStrings . RecentItemSelected += OnRecentReplaceSelected ;
4946 _recentReplaceCombo = new RecentlyUsedComboBox ( _recentReplaceStrings , this . comboBoxReplace ) ;
5047 _recentReplaceCombo . SelectFirstItemByDefault = false ;
5148 }
5249
53- private void OnRecentReplaceSelected ( object sender , MostRecentlyUsedEventArgs e )
54- {
55- this . comboBoxReplace . Text = e . Selection ;
56- }
57-
58- private void OnRecentFindSelected ( object sender , MostRecentlyUsedEventArgs e )
59- {
60- this . comboBoxFind . Text = e . Selection ;
61- }
62-
6350 protected override void OnDpiChanged ( DpiChangedEventArgs e )
6451 {
6552 base . OnDpiChanged ( e ) ;
6653 this . PerformLayout ( ) ;
6754 }
68-
69- void comboBoxFind_LostFocus ( object sender , EventArgs e )
70- {
71- return ;
72- }
73-
55+
7456 void comboBoxFilter_SelectedValueChanged ( object sender , EventArgs e )
7557 {
7658 this . _filter = ( SearchFilter ) this . comboBoxFilter . SelectedItem ;
@@ -125,9 +107,9 @@ void OnNotFound()
125107 this . comboBoxFind . Focus ( ) ;
126108 }
127109
128- void OnFindDone ( )
110+ void OnFindDone ( bool didReplace )
129111 {
130- MessageBox . Show ( this . Window , SR . FindNextDonePrompt , SR . ReplaceCompleteCaption , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
112+ MessageBox . Show ( this . Window , SR . FindNextDonePrompt , didReplace ? SR . ReplaceCompleteCaption : SR . FindErrorCaption , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
131113 this . comboBoxFind . Focus ( ) ;
132114 }
133115
@@ -154,12 +136,8 @@ void DoReplace()
154136 try
155137 {
156138 string replacement = this . comboBoxReplace . Text ;
157- if ( ! string . IsNullOrWhiteSpace ( replacement ) )
158- {
159- this . _recentReplaceStrings . AddItem ( replacement ) ;
160- }
161- _target . ReplaceCurrent ( replacement ) ;
162- FindNext ( false ) ;
139+ bool didReplace = _target . ReplaceCurrent ( replacement ) ;
140+ FindNext ( false , didReplace ) ;
163141 }
164142 catch ( Exception ex )
165143 {
@@ -197,7 +175,7 @@ void buttonReplaceAll_Click(object sender, EventArgs e)
197175 }
198176 }
199177
200- bool FindNext ( bool quiet )
178+ bool FindNext ( bool quiet , bool didReplace = false )
201179 {
202180
203181 FindFlags flags = FindFlags . Normal ;
@@ -208,6 +186,10 @@ bool FindNext(bool quiet)
208186 if ( this . radioButtonUp . Checked ) flags |= FindFlags . Backwards ;
209187
210188 string expr = this . Expression ;
189+ if ( expr . Contains ( " " ) && this . checkBoxWholeWord . Checked )
190+ {
191+ throw new Exception ( SR . FindWholeWordOnlyFindsWords ) ;
192+ }
211193 this . _recentFindStrings . AddItem ( expr ) ;
212194
213195 _lastFlags = flags ;
@@ -220,13 +202,17 @@ bool FindNext(bool quiet)
220202 }
221203 if ( ! quiet )
222204 {
205+ if ( didReplace && rc == FindResult . None )
206+ {
207+ rc = FindResult . NoMore ;
208+ }
223209 if ( rc == FindResult . None )
224210 {
225211 OnNotFound ( ) ;
226212 }
227213 else if ( rc == FindResult . NoMore )
228214 {
229- OnFindDone ( ) ;
215+ OnFindDone ( didReplace ) ;
230216 }
231217 }
232218 return rc == FindResult . Found ;
@@ -261,7 +247,7 @@ public void FindAgain(bool reverse)
261247 }
262248 else if ( rc == FindResult . NoMore )
263249 {
264- OnFindDone ( ) ;
250+ OnFindDone ( false ) ;
265251 }
266252 }
267253 catch ( Exception ex )
0 commit comments