@@ -19,7 +19,7 @@ namespace FindInFiles
1919 /// </summary>
2020 public partial class MainWindow : Window
2121 {
22- string [ ] fileExtensions = new [ ] { "*.txt" , "*.shader" , "*.cs" , "*.log" , "*.js" , "*.cging" , "*.rtf" } ;
22+ string [ ] fileExtensions ;
2323 const int previewSnippetLength = 32 ;
2424 const int maxRecentItems = 32 ;
2525 bool isSearching = false ;
@@ -45,6 +45,10 @@ void Start()
4545 this . Width = Properties . Settings . Default . windowWidth ;
4646 this . Height = Properties . Settings . Default . windowHeight ;
4747
48+ // get extensions
49+ txtExtensions . Text = Properties . Settings . Default . extensionList ;
50+ RefreshExtensionsList ( ) ;
51+
4852 // restore search history
4953 cmbSearch . ItemsSource = Properties . Settings . Default . recentSearches ;
5054 cmbFolder . ItemsSource = Properties . Settings . Default . recentFolders ;
@@ -79,6 +83,7 @@ void OnWindowClose(object sender, CancelEventArgs e)
7983 {
8084 Properties . Settings . Default . windowWidth = ( int ) this . Width ;
8185 Properties . Settings . Default . windowHeight = ( int ) this . Height ;
86+ Properties . Settings . Default . extensionList = txtExtensions . Text ;
8287 Properties . Settings . Default . Save ( ) ;
8388 }
8489
@@ -95,13 +100,14 @@ void AddSearchHistory(string searchString)
95100 Properties . Settings . Default . recentSearches = new StringCollection ( ) ;
96101 }
97102
98- // remove old items
103+ // remove old items if too many
99104 if ( Properties . Settings . Default . recentSearches . Count > maxRecentItems )
100105 {
106+ Console . WriteLine ( "too many items, removing " + Properties . Settings . Default . recentSearches [ 0 ] ) ;
101107 Properties . Settings . Default . recentSearches . RemoveAt ( 0 ) ;
102108 }
103109
104- // skip if duplicate
110+ // skip if duplicate already in list
105111 if ( Properties . Settings . Default . recentSearches . Contains ( searchString ) == false )
106112 {
107113 Properties . Settings . Default . recentSearches . Add ( searchString ) ;
@@ -212,6 +218,7 @@ void Search(string searchString, string sourceFolder)
212218 int searchLen = searchString . Length ;
213219 if ( searchLen < 2 ) return ;
214220 AddSearchHistory ( cmbSearch . Text ) ;
221+ AddFolderHistory ( cmbFolder . Text ) ;
215222
216223 // validate folder
217224 if ( Directory . Exists ( sourceFolder ) == false ) return ;
@@ -243,7 +250,6 @@ void SearchLoop(System.Object a)
243250 {
244251 if ( isSearching == false )
245252 {
246- Console . WriteLine ( "exit" ) ;
247253 break ;
248254 }
249255 // brute-search, measure later..
@@ -298,6 +304,34 @@ private void OnExit(object sender, EventArgs e)
298304 isSearching = false ;
299305 }
300306
307+ private void RefreshExtensionsList ( )
308+ {
309+ var newExtensions = txtExtensions . Text . Split ( '|' ) ;
310+ if ( newExtensions != null && newExtensions . Length > 0 )
311+ {
312+ fileExtensions = newExtensions ;
313+ }
314+ else // use default list if nothing else
315+ {
316+ fileExtensions = new [ ] { "*.txt" , "*.shader" , "*.cs" , "*.log" , "*.js" , "*.cginc" , "*.rtf" } ;
317+ }
318+ }
319+
320+ private void OnLostFocusExtensions ( object sender , EventArgs e )
321+ {
322+ RefreshExtensionsList ( ) ;
323+ }
324+
325+ // enter pressed in extensions textbox
326+ private void txtExtensions_KeyUp ( object sender , KeyEventArgs e )
327+ {
328+ if ( e . Key == Key . Enter )
329+ {
330+ RefreshExtensionsList ( ) ;
331+ cmbSearch . Focus ( ) ;
332+ }
333+ }
334+
301335 } // class
302336} // namespace
303337
0 commit comments