@@ -231,7 +231,11 @@ export function getResolvedConnectionSpec(key: string, dflt: any): any {
231231 */
232232export const cspApps : Map < string , string [ ] > = new Map ( ) ;
233233
234- export async function checkConnection ( clearCookies = false , uri ?: vscode . Uri ) : Promise < void > {
234+ export async function checkConnection (
235+ clearCookies = false ,
236+ uri ?: vscode . Uri ,
237+ triggerRefreshes ?: boolean
238+ ) : Promise < void > {
235239 // Do nothing if already checking the connection
236240 if ( checkingConnection ) {
237241 return ;
@@ -418,10 +422,18 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
418422 } )
419423 . finally ( ( ) => {
420424 checkingConnection = false ;
421- setTimeout ( ( ) => {
422- explorerProvider . refresh ( ) ;
423- projectsExplorerProvider . refresh ( ) ;
424- } , 20 ) ;
425+ if ( triggerRefreshes ) {
426+ setTimeout ( ( ) => {
427+ explorerProvider . refresh ( ) ;
428+ projectsExplorerProvider . refresh ( ) ;
429+ // Refreshing Files Explorer also switches to it, so only do this if the uri is part of the workspace,
430+ // otherwise files opened from ObjectScript Explorer (objectscript:// or isfs:// depending on the "objectscript.serverSideEditing" setting)
431+ // will cause an unwanted switch.
432+ if ( uri && schemas . includes ( uri . scheme ) && vscode . workspace . getWorkspaceFolder ( uri ) ) {
433+ vscode . commands . executeCommand ( "workbench.files.action.refreshFilesExplorer" ) ;
434+ }
435+ } , 20 ) ;
436+ }
425437 } ) ;
426438}
427439
@@ -594,7 +606,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
594606 try {
595607 await resolveConnectionSpec ( serverName ) ;
596608 } finally {
597- await checkConnection ( true , uri ) ;
609+ await checkConnection ( true , uri , true ) ;
598610 }
599611 } catch ( _ ) {
600612 // Ignore any failure
@@ -1060,7 +1072,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10601072 refreshFilesExplorer = true ;
10611073 }
10621074 try {
1063- await checkConnection ( true , folder . uri ) ;
1075+ await checkConnection ( true , folder . uri , true ) ;
10641076 } catch ( _ ) {
10651077 continue ;
10661078 }
0 commit comments