Skip to content

Commit c939a63

Browse files
committed
Add auto complete text to results
1 parent 5bfddf2 commit c939a63

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ResultCreator.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
using System;
33
using System.Collections.Generic;
4+
using System.Linq;
45
using ScipBe.Common.Office.OneNote;
56

67
namespace Flow.Launcher.Plugin.OneNote
@@ -45,16 +46,15 @@ public Result CreatePageResult(IOneNoteExtPage page, List<int> highlightingData
4546

4647
public Result CreatePageResult(IOneNotePage page, IOneNoteSection section, IOneNoteNotebook notebook, List<int> highlightingData = null)
4748
{
48-
var path = GetNicePath(section, notebook, true);
4949
return new Result
5050
{
5151
Title = page.Name,
52-
SubTitle = path,
5352
TitleToolTip = $"Created: {page.DateTime}\nLast Modified: {page.LastModified}",
54-
SubTitleToolTip = path,
53+
TitleHighlightData = highlightingData,
54+
SubTitle = GetNicePath(section, notebook, true),
55+
AutoCompleteText = $"{context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}{LastSelectedNotebook.Name}\\{section.Name}\\{page.Name}",
5556
IcoPath = Icons.Logo,
5657
ContextData = page,
57-
TitleHighlightData = highlightingData,
5858
Action = c =>
5959
{
6060
LastSelectedNotebook = null;
@@ -67,35 +67,41 @@ public Result CreatePageResult(IOneNotePage page, IOneNoteSection section, IOneN
6767

6868
public Result CreateSectionResult(IOneNoteExtSection section, IOneNoteExtNotebook notebook, List<int> highlightData = null)
6969
{
70-
var path = GetNicePath(section, notebook, false);
70+
string path = GetNicePath(section, notebook, false);
71+
string autoCompleteText = $"{context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}{LastSelectedNotebook.Name}\\{section.Name}\\";
7172
return new Result
7273
{
7374
Title = section.Name,
74-
SubTitle = path, // + " | " + section.Pages.Count().ToString(),
7575
TitleHighlightData = highlightData,
76+
SubTitle = path,
77+
SubTitleToolTip = $"{path} | Number of pages: {section.Pages.Count()}",
78+
AutoCompleteText = autoCompleteText,
7679
ContextData = section,
7780
IcoPath = sectionInfo.GetIcon(section.Color.Value),
7881
Action = c =>
7982
{
8083
LastSelectedSection = section;
81-
context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}{LastSelectedNotebook.Name}\\{section.Name}\\");
84+
context.API.ChangeQuery(autoCompleteText);
8285
return false;
8386
},
8487
};
8588
}
8689

8790
public Result CreateNotebookResult(IOneNoteExtNotebook notebook, List<int> highlightData = null)
8891
{
92+
string autoCompleteText = $"{context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}{notebook.Name}\\";
8993
return new Result
9094
{
9195
Title = notebook.Name,
96+
TitleToolTip = $"Number of sections: {notebook.Sections.Count()}",
9297
TitleHighlightData = highlightData,
98+
AutoCompleteText = autoCompleteText,
9399
ContextData = notebook,
94100
IcoPath = notebookInfo.GetIcon(notebook.Color.Value),
95101
Action = c =>
96102
{
97103
LastSelectedNotebook = notebook;
98-
context.API.ChangeQuery($"{context.CurrentPluginMetadata.ActionKeyword} {Keywords.NotebookExplorer}{notebook.Name}\\");
104+
context.API.ChangeQuery(autoCompleteText);
99105
return false;
100106
},
101107
};

0 commit comments

Comments
 (0)