@@ -934,7 +934,42 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
934
934
} ) ,
935
935
vscode . commands . registerCommand ( "vscode-objectscript.pickProcess" , async ( config ) => {
936
936
const system = config . system ;
937
- const api = new AtelierAPI ( vscode . window . activeTextEditor ?. document . uri ) ;
937
+ let connectionUri = vscode . window . activeTextEditor ?. document . uri ;
938
+ if ( connectionUri ) {
939
+ // Ignore active editor if its document is outside the workspace (e.g. user settings.json)
940
+ connectionUri = vscode . workspace . getWorkspaceFolder ( connectionUri ) ?. uri ;
941
+ }
942
+ if ( ! connectionUri ) {
943
+ // May need to ask the user
944
+ const workspaceFolders = vscode . workspace . workspaceFolders || [ ] ;
945
+ if ( workspaceFolders . length == 0 ) {
946
+ vscode . window . showErrorMessage ( `Attaching to a server process requires a workspace to be open.` , {
947
+ modal : true ,
948
+ } ) ;
949
+ return ;
950
+ }
951
+ if ( workspaceFolders . length == 1 ) {
952
+ connectionUri = workspaceFolders [ 0 ] . uri ;
953
+ } else {
954
+ // Pick from the workspace folders
955
+ connectionUri = (
956
+ await vscode . window . showWorkspaceFolderPick ( {
957
+ ignoreFocusOut : true ,
958
+ placeHolder : "Pick the workspace folder to get server connection information from" ,
959
+ } )
960
+ ) ?. uri ;
961
+ }
962
+ }
963
+ if ( ! connectionUri ) {
964
+ return ;
965
+ }
966
+ const api = new AtelierAPI ( connectionUri ) ;
967
+ if ( ! api . active ) {
968
+ vscode . window . showErrorMessage ( `No active server connection.` , {
969
+ modal : true ,
970
+ } ) ;
971
+ return ;
972
+ }
938
973
939
974
const list = await api . getJobs ( system ) . then ( async ( jobData ) => {
940
975
// NOTE: We do not know if the current user has permissions to other namespaces
@@ -969,14 +1004,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
969
1004
} ) ;
970
1005
} ) ;
971
1006
if ( ! list . length ) {
972
- vscode . window . showInformationMessage ( `No attachable processes are running in ${ api . ns } .` , {
1007
+ vscode . window . showInformationMessage ( `No attachable processes are running in ${ api . ns } on ' ${ api . serverId } ' .` , {
973
1008
modal : true ,
974
1009
} ) ;
975
1010
return ;
976
1011
}
977
1012
return vscode . window
978
1013
. showQuickPick < vscode . QuickPickItem > ( list , {
979
- placeHolder : " Pick the process to attach to" ,
1014
+ placeHolder : ` Pick the process to attach to in ${ api . ns } on ' ${ api . serverId } '` ,
980
1015
matchOnDescription : true ,
981
1016
} )
982
1017
. then ( ( value ) => {
0 commit comments