@@ -14,7 +14,7 @@ public class OneNote : IPlugin, IContextMenu
14
14
private readonly string syncIconPath = "Images/refresh.png" ;
15
15
private readonly string recentIconPath = "Images/recent.png" ;
16
16
17
- private readonly string structureKeyword = "nb\\ " ;
17
+ private readonly string structureKeyword = "nb: \\ " ;
18
18
private readonly string recentKeyword = "rcntpgs:" ;
19
19
private readonly int recentPagesCount = 5 ;
20
20
@@ -107,7 +107,7 @@ public List<Result> Query(Query query)
107
107
}
108
108
109
109
return OneNoteProvider . PageItems . OrderByDescending ( pg => pg . LastModified )
110
- . Select ( pg => GetResultFromPage ( pg , null ) )
110
+ . Select ( pg => CreatePageResult ( pg , null ) )
111
111
. Take ( count )
112
112
. ToList ( ) ;
113
113
}
@@ -129,7 +129,7 @@ public List<Result> Query(Query query)
129
129
if ( string . IsNullOrWhiteSpace ( searchString ) ) // Do a normall notebook search
130
130
{
131
131
lastSelectedNotebook = null ;
132
- return OneNoteProvider . NotebookItems . Select ( nb => GetResultFromNotebook ( nb ) ) . ToList ( ) ;
132
+ return OneNoteProvider . NotebookItems . Select ( nb => CreateNotebookResult ( nb ) ) . ToList ( ) ;
133
133
}
134
134
135
135
return OneNoteProvider . NotebookItems . Where ( nb =>
@@ -138,7 +138,7 @@ public List<Result> Query(Query query)
138
138
return true ;
139
139
return TreeQuery ( nb . Name , searchString , out highlightData ) ;
140
140
} )
141
- . Select ( nb => GetResultFromNotebook ( nb , highlightData ) )
141
+ . Select ( nb => CreateNotebookResult ( nb , highlightData ) )
142
142
. ToList ( ) ;
143
143
144
144
case 3 : //Full query for section not complete e.g nb\User Notebook\Happine
@@ -150,15 +150,15 @@ public List<Result> Query(Query query)
150
150
if ( string . IsNullOrWhiteSpace ( searchString ) )
151
151
{
152
152
lastSelectedSection = null ;
153
- return lastSelectedNotebook . Sections . Select ( s => GetResultsFromSection ( s , lastSelectedNotebook ) ) . ToList ( ) ;
153
+ return lastSelectedNotebook . Sections . Select ( s => CreateSectionResult ( s , lastSelectedNotebook ) ) . ToList ( ) ;
154
154
}
155
155
return lastSelectedNotebook . Sections . Where ( s =>
156
156
{
157
157
if ( lastSelectedSection != null && s . ID == lastSelectedSection . ID )
158
158
return true ;
159
159
return TreeQuery ( s . Name , searchString , out highlightData ) ;
160
160
} )
161
- . Select ( s => GetResultsFromSection ( s , lastSelectedNotebook , highlightData ) )
161
+ . Select ( s => CreateSectionResult ( s , lastSelectedNotebook , highlightData ) )
162
162
. ToList ( ) ;
163
163
164
164
case 4 : //Searching pages in a section
@@ -171,10 +171,10 @@ public List<Result> Query(Query query)
171
171
return new List < Result > ( ) ;
172
172
173
173
if ( string . IsNullOrWhiteSpace ( searchString ) )
174
- return lastSelectedSection . Pages . Select ( pg => GetResultFromPage ( pg , lastSelectedSection , lastSelectedNotebook ) ) . ToList ( ) ;
174
+ return lastSelectedSection . Pages . Select ( pg => CreatePageResult ( pg , lastSelectedSection , lastSelectedNotebook ) ) . ToList ( ) ;
175
175
176
176
return lastSelectedSection . Pages . Where ( pg => TreeQuery ( pg . Name , searchString , out highlightData ) )
177
- . Select ( pg => GetResultFromPage ( pg , lastSelectedSection , lastSelectedNotebook , highlightData ) )
177
+ . Select ( pg => CreatePageResult ( pg , lastSelectedSection , lastSelectedNotebook , highlightData ) )
178
178
. ToList ( ) ;
179
179
180
180
default :
@@ -184,7 +184,7 @@ public List<Result> Query(Query query)
184
184
185
185
//Default search
186
186
return OneNoteProvider . FindPages ( query . Search )
187
- . Select ( page => GetResultFromPage ( page , context . API . FuzzySearch ( query . Search , page . Name ) . MatchData ) )
187
+ . Select ( page => CreatePageResult ( page , context . API . FuzzySearch ( query . Search , page . Name ) . MatchData ) )
188
188
. ToList ( ) ;
189
189
190
190
bool TreeQuery ( string itemName , string searchString , out List < int > highlightData )
@@ -230,15 +230,29 @@ public List<Result> LoadContextMenus(Result selectedResult)
230
230
section . Sync ( ) ;
231
231
return true ;
232
232
}
233
- } } ;
233
+ } ,
234
+ new Result
235
+ {
236
+ Title = "One and sync notebook" ,
237
+ SubTitle = lastSelectedNotebook . Name ,
238
+ IcoPath = notebookInfo . GetIcon ( lastSelectedNotebook . Color . Value ) ,
239
+ Action = c =>
240
+ {
241
+ lastSelectedNotebook . Sections . First ( ) . Pages
242
+ . OrderByDescending ( pg => pg . LastModified )
243
+ . First ( )
244
+ . OpenInOneNote ( ) ;
245
+ lastSelectedNotebook . Sync ( ) ;
246
+ return true ;
247
+ }
248
+ }
249
+ } ;
234
250
235
251
default :
236
252
return new List < Result > ( ) ;
237
253
}
238
254
}
239
255
240
-
241
-
242
256
private bool ValidateNotebook ( string notebookName )
243
257
{
244
258
if ( lastSelectedNotebook == null )
@@ -265,12 +279,12 @@ private bool ValidateSection(string sectionName)
265
279
return true ;
266
280
}
267
281
268
- private Result GetResultFromPage ( IOneNoteExtPage page , List < int > highlightingData )
282
+ private Result CreatePageResult ( IOneNoteExtPage page , List < int > highlightingData )
269
283
{
270
- return GetResultFromPage ( page , page . Section , page . Notebook , highlightingData ) ;
284
+ return CreatePageResult ( page , page . Section , page . Notebook , highlightingData ) ;
271
285
}
272
286
273
- private Result GetResultFromPage ( IOneNotePage page , IOneNoteSection section , IOneNoteNotebook notebook , List < int > highlightingData = null )
287
+ private Result CreatePageResult ( IOneNotePage page , IOneNoteSection section , IOneNoteNotebook notebook , List < int > highlightingData = null )
274
288
{
275
289
var sectionPath = section . Path ;
276
290
var index = sectionPath . IndexOf ( notebook . Name ) ;
@@ -294,7 +308,7 @@ private Result GetResultFromPage(IOneNotePage page, IOneNoteSection section, IOn
294
308
} ;
295
309
}
296
310
297
- private Result GetResultsFromSection ( IOneNoteExtSection section , IOneNoteExtNotebook notebook , List < int > highlightData = null )
311
+ private Result CreateSectionResult ( IOneNoteExtSection section , IOneNoteExtNotebook notebook , List < int > highlightData = null )
298
312
{
299
313
var sectionPath = section . Path ;
300
314
var index = sectionPath . IndexOf ( notebook . Name ) ;
@@ -315,7 +329,7 @@ private Result GetResultsFromSection(IOneNoteExtSection section, IOneNoteExtNote
315
329
} ;
316
330
}
317
331
318
- private Result GetResultFromNotebook ( IOneNoteExtNotebook notebook , List < int > highlightData = null )
332
+ private Result CreateNotebookResult ( IOneNoteExtNotebook notebook , List < int > highlightData = null )
319
333
{
320
334
return new Result
321
335
{
0 commit comments