@@ -65,19 +65,16 @@ string ls when ls.StartsWith(settings.Keywords.ScopedSearch) && (parent is OneNo
65
65
{
66
66
var result = rc . CreateOneNoteItemResult ( parent , false , score : 4000 ) ;
67
67
result . Title = $ "Open \" { parent . Name } \" in OneNote";
68
-
69
- if ( lastSearch . StartsWith ( settings . Keywords . TitleSearch ) )
70
- {
71
- result . SubTitle = $ "Now search by title in \" { parent . Name } \" ";
72
- }
73
- else if ( lastSearch . StartsWith ( settings . Keywords . ScopedSearch ) )
74
- {
75
- result . SubTitle = $ "Now searching all pages in \" { parent . Name } \" ";
76
- }
77
- else
68
+ result . SubTitle = lastSearch switch
78
69
{
79
- result . SubTitle = $ "Use \' { settings . Keywords . ScopedSearch } \' to search this item. Use \' { settings . Keywords . TitleSearch } \' to search by title in this item";
80
- }
70
+ string ls when ls . StartsWith ( settings . Keywords . TitleSearch )
71
+ => $ "Now search by title in \" { parent . Name } \" ",
72
+
73
+ string ls when ls . StartsWith ( settings . Keywords . ScopedSearch )
74
+ => $ "Now searching all pages in \" { parent . Name } \" ",
75
+
76
+ _ => $ "Use \' { settings . Keywords . ScopedSearch } \' to search this item. Use \' { settings . Keywords . TitleSearch } \' to search by title in this item",
77
+ } ;
81
78
82
79
results . Add ( result ) ;
83
80
}
@@ -87,14 +84,13 @@ string ls when ls.StartsWith(settings.Keywords.ScopedSearch) && (parent is OneNo
87
84
88
85
private List < Result > NotebookDefaultSearch ( IOneNoteItem parent , IEnumerable < IOneNoteItem > collection , string lastSearch )
89
86
{
90
- List < Result > results ;
91
87
List < int > highlightData = null ;
92
88
int score = 0 ;
93
89
94
- results = collection . Where ( SettingsCheck )
95
- . Where ( item => FuzzySearch ( item . Name , lastSearch , out highlightData , out score ) )
96
- . Select ( item => rc . CreateOneNoteItemResult ( item , true , highlightData , score ) )
97
- . ToList ( ) ;
90
+ var results = collection . Where ( SettingsCheck )
91
+ . Where ( item => FuzzySearch ( item . Name , lastSearch , out highlightData , out score ) )
92
+ . Select ( item => rc . CreateOneNoteItemResult ( item , true , highlightData , score ) )
93
+ . ToList ( ) ;
98
94
99
95
AddCreateNewOneNoteItemResults ( results , parent , lastSearch ) ;
100
96
return results ;
@@ -150,8 +146,8 @@ private List<Result> ScopedSearch(string query, IOneNoteItem parent)
150
146
var results = new List < Result > ( ) ;
151
147
152
148
results = OneNoteApplication . FindPages ( parent , currentSearch )
153
- . Select ( pg => rc . CreatePageResult ( pg , currentSearch ) )
154
- . ToList ( ) ;
149
+ . Select ( pg => rc . CreatePageResult ( pg , currentSearch ) )
150
+ . ToList ( ) ;
155
151
156
152
if ( ! results . Any ( ) )
157
153
results = ResultCreator . NoMatchesFoundResult ( ) ;
@@ -190,13 +186,10 @@ public List<Result> DefaultSearch(string query)
190
186
{
191
187
//Check for invalid start of query i.e. symbols
192
188
if ( ! char . IsLetterOrDigit ( query [ 0 ] ) )
193
- {
194
189
return ResultCreator . InvalidQuery ( ) ;
195
- }
196
190
197
191
var results = OneNoteApplication . FindPages ( query )
198
- . Select ( pg => rc . CreatePageResult ( pg , query ) ) ;
199
-
192
+ . Select ( pg => rc . CreatePageResult ( pg , query ) ) ;
200
193
if ( results . Any ( ) )
201
194
return results . ToList ( ) ;
202
195
@@ -210,19 +203,18 @@ public List<Result> TitleSearch(string query, IEnumerable<IOneNoteItem> currentC
210
203
211
204
List < int > highlightData = null ;
212
205
int score = 0 ;
213
- var results = new List < Result > ( ) ;
214
206
215
207
var currentSearch = query [ settings . Keywords . TitleSearch . Length ..] ;
216
208
217
- results = currentCollection . Traverse ( item =>
218
- {
219
- if ( ! SettingsCheck ( item ) )
220
- return false ;
209
+ var results = currentCollection . Traverse ( item =>
210
+ {
211
+ if ( ! SettingsCheck ( item ) )
212
+ return false ;
221
213
222
- return FuzzySearch ( item . Name , currentSearch , out highlightData , out score ) ;
223
- } )
224
- . Select ( item => rc . CreateOneNoteItemResult ( item , false , highlightData , score ) )
225
- . ToList ( ) ;
214
+ return FuzzySearch ( item . Name , currentSearch , out highlightData , out score ) ;
215
+ } )
216
+ . Select ( item => rc . CreateOneNoteItemResult ( item , false , highlightData , score ) )
217
+ . ToList ( ) ;
226
218
227
219
if ( ! results . Any ( ) )
228
220
results = ResultCreator . NoMatchesFoundResult ( ) ;
0 commit comments