@@ -94,7 +94,7 @@ public List<Result> Query(Query query)
94
94
int count = recentPagesCount ;
95
95
if ( query . FirstSearch . Length > Constants . RecentKeyword . Length && int . TryParse ( query . FirstSearch [ Constants . RecentKeyword . Length ..] , out int userChosenCount ) )
96
96
count = userChosenCount ;
97
-
97
+
98
98
return OneNoteProvider . PageItems . OrderByDescending ( pg => pg . LastModified )
99
99
. Take ( count )
100
100
. Select ( pg =>
@@ -113,10 +113,21 @@ public List<Result> Query(Query query)
113
113
return notebookExplorer . Explore ( query ) ;
114
114
115
115
//Default search
116
- return OneNoteProvider . FindPages ( query . Search )
117
- . Select ( pg => rc . CreatePageResult ( pg , context . API . FuzzySearch ( query . Search , pg . Name ) . MatchData ) )
118
- . ToList ( ) ;
116
+ var searches = OneNoteProvider . FindPages ( query . Search )
117
+ . Select ( pg => rc . CreatePageResult ( pg , context . API . FuzzySearch ( query . Search , pg . Name ) . MatchData ) ) ;
119
118
119
+ if ( searches . Any ( ) )
120
+ return searches . ToList ( ) ;
121
+
122
+ return new List < Result >
123
+ {
124
+ new Result
125
+ {
126
+ Title = "No matches found" ,
127
+ SubTitle = "Try searching something else, or syncing your notebooks." ,
128
+ IcoPath = Constants . LogoIconPath ,
129
+ }
130
+ } ;
120
131
}
121
132
122
133
public List < Result > LoadContextMenus ( Result selectedResult )
@@ -138,35 +149,35 @@ public List<Result> LoadContextMenus(Result selectedResult)
138
149
lastSelectedNotebook = null ;
139
150
return true ;
140
151
} ;
141
- return new List < Result > { result } ;
152
+ return new List < Result > { result } ;
142
153
case IOneNoteExtSection section :
143
154
Result sResult = rc . CreateSectionResult ( section , lastSelectedNotebook ) ;
144
155
sResult . Title = "Open and sync section" ;
145
156
sResult . SubTitle = section . Name ;
146
157
sResult . ContextData = null ;
147
- sResult . Action = c =>
158
+ sResult . Action = c =>
148
159
{
149
- section . Pages . OrderByDescending ( pg => pg . LastModified )
150
- . First ( )
151
- . OpenInOneNote ( ) ;
152
- section . Sync ( ) ;
153
- lastSelectedNotebook = null ;
154
- lastSelectedSection = null ;
155
- return true ;
160
+ section . Pages . OrderByDescending ( pg => pg . LastModified )
161
+ . First ( )
162
+ . OpenInOneNote ( ) ;
163
+ section . Sync ( ) ;
164
+ lastSelectedNotebook = null ;
165
+ lastSelectedSection = null ;
166
+ return true ;
156
167
} ;
157
168
Result nbResult = rc . CreateNotebookResult ( lastSelectedNotebook ) ;
158
169
nbResult . Title = "Open and sync notebook" ;
159
170
nbResult . SubTitle = lastSelectedNotebook . Name ;
160
171
nbResult . Action = c =>
161
172
{
162
- lastSelectedNotebook . Sections . First ( ) . Pages
163
- . OrderByDescending ( pg => pg . LastModified )
164
- . First ( )
165
- . OpenInOneNote ( ) ;
166
- lastSelectedNotebook . Sync ( ) ;
167
- lastSelectedNotebook = null ;
168
- lastSelectedSection = null ;
169
- return true ;
173
+ lastSelectedNotebook . Sections . First ( ) . Pages
174
+ . OrderByDescending ( pg => pg . LastModified )
175
+ . First ( )
176
+ . OpenInOneNote ( ) ;
177
+ lastSelectedNotebook . Sync ( ) ;
178
+ lastSelectedNotebook = null ;
179
+ lastSelectedSection = null ;
180
+ return true ;
170
181
} ;
171
182
return new List < Result > { sResult , nbResult , } ;
172
183
default :
@@ -177,17 +188,17 @@ public List<Result> LoadContextMenus(Result selectedResult)
177
188
private static string GetLastEdited ( TimeSpan diff )
178
189
{
179
190
string lastEdited = "Last editied " ;
180
- if ( PluralCheck ( diff . TotalDays , "day" , ref lastEdited )
181
- || PluralCheck ( diff . TotalHours , "hour" , ref lastEdited )
182
- || PluralCheck ( diff . TotalMinutes , "min" , ref lastEdited )
191
+ if ( PluralCheck ( diff . TotalDays , "day" , ref lastEdited )
192
+ || PluralCheck ( diff . TotalHours , "hour" , ref lastEdited )
193
+ || PluralCheck ( diff . TotalMinutes , "min" , ref lastEdited )
183
194
|| PluralCheck ( diff . TotalSeconds , "sec" , ref lastEdited ) )
184
195
return lastEdited ;
185
196
else
186
197
return lastEdited += "Now." ;
187
198
bool PluralCheck ( double totalTime , string timeType , ref string lastEdited )
188
199
{
189
200
var roundedTime = ( int ) Math . Round ( totalTime ) ;
190
- if ( roundedTime > 0 )
201
+ if ( roundedTime > 0 )
191
202
{
192
203
string plural = roundedTime == 1 ? "" : "s" ;
193
204
lastEdited += $ "{ roundedTime } { timeType } { plural } ago.";
0 commit comments