11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using Odotocodot . OneNote . Linq ;
5- using Odotocodot . OneNote . Linq . Abstractions ;
4+ using LinqToOneNote ;
5+ using LinqToOneNote . Abstractions ;
6+ using OneNoteApp = LinqToOneNote . OneNote ;
7+
68
79namespace Flow . Launcher . Plugin . OneNote . Search
810{
@@ -22,7 +24,7 @@ public override List<Result> GetResults(string query)
2224
2325 List < Result > results = search switch
2426 {
25- { } when search . StartsWithOrd ( Keywords . TitleSearch ) && parent is not OneNotePage => titleSearch . Filter ( search , parent , collection ) ,
27+ { } when search . StartsWithOrd ( Keywords . TitleSearch ) && parent is not Page => titleSearch . Filter ( search , parent , collection ) ,
2628 { } when search . StartsWithOrd ( Keywords . ScopedSearch ) && parent is INotebookOrSectionGroup => ScopedSearch ( search , parent ) ,
2729 { } when ! string . IsNullOrWhiteSpace ( search ) => Explorer ( search , parent , collection ) ,
2830 _ => ShowAll ( parent , collection ) ,
@@ -42,7 +44,7 @@ private bool ValidateSearch(string query, out string? lastSearch, out IOneNoteIt
4244 {
4345 lastSearch = null ;
4446 parent = null ;
45- collection = OneNoteApplication . GetNotebooks ( ) ;
47+ collection = OneNoteApp . GetFullHierarchy ( ) . Notebooks ;
4648
4749 string search = query [ ( query . IndexOf ( Keywords . NotebookExplorer , StringComparison . Ordinal ) + Keywords . NotebookExplorer . Length ) ..] ;
4850 const string separator = Keywords . NotebookExplorerSeparator ;
@@ -85,9 +87,9 @@ private List<Result> ScopedSearch(string query, IOneNoteItem parent)
8587
8688 string currentSearch = query [ Keywords . TitleSearch . Length ..] ;
8789
88- var results = OneNoteApplication . FindPages ( currentSearch , parent )
89- . Select ( pg => resultCreator . CreatePageResult ( pg , currentSearch ) )
90- . ToList ( ) ;
90+ var results = OneNoteApp . FindPages ( currentSearch , parent )
91+ . Select ( pg => resultCreator . CreatePageResult ( pg , currentSearch ) )
92+ . ToList ( ) ;
9193
9294 return results . Any ( ) ? results : ResultCreator . NoMatchesFound ( ) ;
9395 }
@@ -100,7 +102,7 @@ private List<Result> Explorer(string search, IOneNoteItem? parent, IEnumerable<I
100102 . ToList ( ) ;
101103
102104 // If parent is a section, pages inside can have the same name
103- if ( parent is not OneNoteSection && results . Any ( result => string . Equals ( search . Trim ( ) , result . Title , StringComparison . OrdinalIgnoreCase ) ) )
105+ if ( parent is not Section && results . Any ( result => string . Equals ( search . Trim ( ) , result . Title , StringComparison . OrdinalIgnoreCase ) ) )
104106 return results ;
105107
106108 if ( parent ? . IsInRecycleBin ( ) == true )
@@ -116,7 +118,7 @@ private List<Result> Explorer(string search, IOneNoteItem? parent, IEnumerable<I
116118 results . Add ( resultCreator . CreateNewSectionResult ( search , x ) ) ;
117119 results . Add ( resultCreator . CreateNewSectionGroupResult ( search , x ) ) ;
118120 break ;
119- case OneNoteSection section :
121+ case Section section :
120122 if ( ! section . Locked )
121123 {
122124 results . Add ( resultCreator . CreateNewPageResult ( search , section ) ) ;
0 commit comments