@@ -13,19 +13,26 @@ public static class ResultManager
13
13
{
14
14
private static PluginInitContext Context ;
15
15
private static Settings Settings { get ; set ; }
16
- public static object Keyword { get ; private set ; }
17
16
18
17
public static void Init ( PluginInitContext context , Settings settings )
19
18
{
20
19
Context = context ;
21
20
Settings = settings ;
22
- Keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
23
- Keyword = Keyword . ToString ( ) == Query . GlobalPluginWildcardSign ? string . Empty : Keyword + " " ;
24
21
}
25
22
26
- public static string ChangeToPath ( string path )
23
+ private static string GetPathWithActionKeyword ( string path , ResultType type )
27
24
{
28
- return path . EndsWith ( Constants . DirectorySeperator ) ? path : path + Constants . DirectorySeperator ;
25
+ // one of it is enabled
26
+ var keyword = Settings . SearchActionKeywordEnabled ? Settings . SearchActionKeyword : Settings . PathSearchActionKeyword ;
27
+
28
+ keyword = keyword == Query . GlobalPluginWildcardSign ? string . Empty : keyword + " " ;
29
+
30
+ var formatted_path = path ;
31
+
32
+ if ( type == ResultType . Folder )
33
+ formatted_path = path . EndsWith ( Constants . DirectorySeperator ) ? path : path + Constants . DirectorySeperator ;
34
+
35
+ return $ "{ keyword } { formatted_path } ";
29
36
}
30
37
31
38
internal static Result CreateFolderResult ( string title , string subtitle , string path , Query query , int score = 0 , bool showIndexState = false , bool windowsIndexed = false )
@@ -35,7 +42,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
35
42
Title = title ,
36
43
IcoPath = path ,
37
44
SubTitle = subtitle ,
38
- AutoCompleteText = $ " { Keyword } { ChangeToPath ( path ) } " ,
45
+ AutoCompleteText = GetPathWithActionKeyword ( path , ResultType . Folder ) ,
39
46
TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , title ) . MatchData ,
40
47
Action = c =>
41
48
{
@@ -52,7 +59,9 @@ internal static Result CreateFolderResult(string title, string subtitle, string
52
59
return false ;
53
60
}
54
61
}
55
- Context . API . ChangeQuery ( $ "{ Keyword } { ChangeToPath ( path ) } ") ;
62
+
63
+ Context . API . ChangeQuery ( GetPathWithActionKeyword ( path , ResultType . Folder ) ) ;
64
+
56
65
return false ;
57
66
} ,
58
67
Score = score ,
@@ -100,6 +109,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, bool windowsIn
100
109
Title = title ,
101
110
SubTitle = $ "Use > to search within { subtitleFolderName } , " +
102
111
$ "* to search for file extensions or >* to combine both searches.",
112
+ AutoCompleteText = GetPathWithActionKeyword ( retrievedDirectoryPath , ResultType . Folder ) ,
103
113
IcoPath = retrievedDirectoryPath ,
104
114
Score = 500 ,
105
115
Action = c =>
@@ -126,7 +136,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
126
136
Title = Path . GetFileName ( filePath ) ,
127
137
SubTitle = filePath ,
128
138
IcoPath = filePath ,
129
- AutoCompleteText = filePath ,
139
+ AutoCompleteText = GetPathWithActionKeyword ( filePath , ResultType . File ) ,
130
140
TitleHighlightData = StringMatcher . FuzzySearch ( query . Search , Path . GetFileName ( filePath ) ) . MatchData ,
131
141
Score = score ,
132
142
Action = c =>
0 commit comments