@@ -19,15 +19,15 @@ namespace Flow.Plugin.VSCodeWorkspaces
19
19
20
20
public class Main : IPlugin , IPluginI18n , ISettingProvider , IContextMenu
21
21
{
22
- internal static PluginInitContext _context { get ; private set ; }
22
+ internal static PluginInitContext Context { get ; private set ; }
23
23
24
24
private static Settings _settings ;
25
25
26
26
public string Name => GetTranslatedPluginTitle ( ) ;
27
27
28
28
public string Description => GetTranslatedPluginDescription ( ) ;
29
29
30
- private VSCodeInstance defaultInstalce ;
30
+ private VSCodeInstance _defaultInstance ;
31
31
32
32
private readonly VSCodeWorkspacesApi _workspacesApi = new ( ) ;
33
33
@@ -36,13 +36,13 @@ public class Main : IPlugin, IPluginI18n, ISettingProvider, IContextMenu
36
36
public List < Result > Query ( Query query )
37
37
{
38
38
var results = new List < Result > ( ) ;
39
- var workspaces = new List < VSCodeWorkspace > ( ) ;
39
+ var workspaces = new List < VsCodeWorkspace > ( ) ;
40
40
41
41
// User defined extra workspaces
42
- if ( defaultInstalce != null )
42
+ if ( _defaultInstance != null )
43
43
{
44
44
workspaces . AddRange ( _settings . CustomWorkspaces . Select ( uri =>
45
- VSCodeWorkspacesApi . ParseVSCodeUri ( uri , defaultInstalce ) ) ) ;
45
+ VSCodeWorkspacesApi . ParseVSCodeUri ( uri , _defaultInstance ) ) ) ;
46
46
}
47
47
48
48
// Search opened workspaces
@@ -95,9 +95,9 @@ public List<Result> Query(Query query)
95
95
}
96
96
catch ( Win32Exception )
97
97
{
98
- var name = $ "{ _context . CurrentPluginMetadata . Name } ";
98
+ var name = $ "{ Context . CurrentPluginMetadata . Name } ";
99
99
string msg = Resources . OpenFail ;
100
- _context . API . ShowMsg ( name , msg , string . Empty ) ;
100
+ Context . API . ShowMsg ( name , msg , string . Empty ) ;
101
101
hide = false ;
102
102
}
103
103
@@ -113,7 +113,7 @@ public List<Result> Query(Query query)
113
113
{
114
114
results = results . Where ( r =>
115
115
{
116
- r . Score = _context . API . FuzzySearch ( query . Search , r . Title ) . Score ;
116
+ r . Score = Context . API . FuzzySearch ( query . Search , r . Title ) . Score ;
117
117
return r . Score > 0 ;
118
118
} ) . ToList ( ) ;
119
119
}
@@ -122,20 +122,20 @@ public List<Result> Query(Query query)
122
122
return results ;
123
123
}
124
124
125
- private Result CreateWorkspaceResult ( VSCodeWorkspace ws )
125
+ private static Result CreateWorkspaceResult ( VsCodeWorkspace ws )
126
126
{
127
127
var title = $ "{ ws . FolderName } ";
128
128
var typeWorkspace = ws . WorkspaceTypeToString ( ) ;
129
129
130
- if ( ws . TypeWorkspace != TypeWorkspace . Local )
130
+ if ( ws . WorkspaceLocation != WorkspaceLocation . Local )
131
131
{
132
- title = ws . Lable != null
133
- ? $ "{ ws . Lable } "
132
+ title = ws . Label != null
133
+ ? $ "{ ws . Label } "
134
134
: $ "{ title } { ( ws . ExtraInfo != null ? $ " - { ws . ExtraInfo } " : string . Empty ) } ({ typeWorkspace } )";
135
135
}
136
136
137
137
var tooltip =
138
- $ "{ Resources . Workspace } { ( ws . TypeWorkspace != TypeWorkspace . Local ? $ " { Resources . In } { typeWorkspace } " : string . Empty ) } : { SystemPath . RealPath ( ws . RelativePath ) } ";
138
+ $ "{ Resources . Workspace } { ( ws . WorkspaceLocation != WorkspaceLocation . Local ? $ " { Resources . In } { typeWorkspace } " : string . Empty ) } : { SystemPath . RealPath ( ws . RelativePath ) } ";
139
139
140
140
return new Result
141
141
{
@@ -150,7 +150,7 @@ private Result CreateWorkspaceResult(VSCodeWorkspace ws)
150
150
var modifierKeys = c . SpecialKeyState . ToModifierKeys ( ) ;
151
151
if ( modifierKeys == System . Windows . Input . ModifierKeys . Control )
152
152
{
153
- _context . API . OpenDirectory ( SystemPath . RealPath ( ws . RelativePath ) ) ;
153
+ Context . API . OpenDirectory ( SystemPath . RealPath ( ws . RelativePath ) ) ;
154
154
return true ;
155
155
}
156
156
@@ -160,17 +160,21 @@ private Result CreateWorkspaceResult(VSCodeWorkspace ws)
160
160
UseShellExecute = true ,
161
161
WindowStyle = ProcessWindowStyle . Hidden ,
162
162
} ;
163
- process . ArgumentList . Add ( "--folder-uri" ) ;
163
+
164
+ process . ArgumentList . Add ( ws . WorkspaceType == WorkspaceType . Workspace
165
+ ? "--file-uri"
166
+ : "--folder-uri" ) ;
167
+
164
168
process . ArgumentList . Add ( ws . Path ) ;
165
169
166
170
Process . Start ( process ) ;
167
171
return true ;
168
172
}
169
173
catch ( Win32Exception )
170
174
{
171
- var name = $ "{ _context . CurrentPluginMetadata . Name } ";
175
+ var name = $ "{ Context . CurrentPluginMetadata . Name } ";
172
176
string msg = Resources . OpenFail ;
173
- _context . API . ShowMsg ( name , msg , string . Empty ) ;
177
+ Context . API . ShowMsg ( name , msg , string . Empty ) ;
174
178
}
175
179
176
180
return false ;
@@ -181,17 +185,17 @@ private Result CreateWorkspaceResult(VSCodeWorkspace ws)
181
185
182
186
public void Init ( PluginInitContext context )
183
187
{
184
- _context = context ;
188
+ Context = context ;
185
189
_settings = context . API . LoadSettingJsonStorage < Settings > ( ) ;
186
190
187
191
VSCodeInstances . LoadVSCodeInstances ( ) ;
188
192
189
193
// Prefer stable version, or the first one we got
190
- defaultInstalce = VSCodeInstances . Instances . Find ( e => e . VSCodeVersion == VSCodeVersion . Stable ) ??
194
+ _defaultInstance = VSCodeInstances . Instances . Find ( e => e . VSCodeVersion == VSCodeVersion . Stable ) ??
191
195
VSCodeInstances . Instances . FirstOrDefault ( ) ;
192
196
}
193
197
194
- public Control CreateSettingPanel ( ) => new SettingsView ( _context , _settings ) ;
198
+ public Control CreateSettingPanel ( ) => new SettingsView ( Context , _settings ) ;
195
199
196
200
public void OnCultureInfoChanged ( CultureInfo newCulture )
197
201
{
@@ -211,7 +215,7 @@ public string GetTranslatedPluginDescription()
211
215
public List < Result > LoadContextMenus ( Result selectedResult )
212
216
{
213
217
List < Result > results = new ( ) ;
214
- if ( selectedResult . ContextData is VSCodeWorkspace ws && ws . TypeWorkspace == TypeWorkspace . Local )
218
+ if ( selectedResult . ContextData is VsCodeWorkspace ws && ws . WorkspaceLocation == WorkspaceLocation . Local )
215
219
{
216
220
results . Add ( new Result
217
221
{
@@ -221,7 +225,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
221
225
TitleToolTip = Resources . OpenFolderSubTitle ,
222
226
Action = c =>
223
227
{
224
- _context . API . OpenDirectory ( SystemPath . RealPath ( ws . RelativePath ) ) ;
228
+ Context . API . OpenDirectory ( SystemPath . RealPath ( ws . RelativePath ) ) ;
225
229
return true ;
226
230
} ,
227
231
ContextData = ws ,
0 commit comments