@@ -13,6 +13,7 @@ import {
13
13
documentContentProvider ,
14
14
filesystemSchemas ,
15
15
outputLangId ,
16
+ OBJECTSCRIPTXML_FILE_SCHEMA ,
16
17
} from "../extension" ;
17
18
import { getCategory } from "../commands/export" ;
18
19
import { isCSP , isfsDocumentName } from "../providers/FileSystemProvider/FileSystemProvider" ;
@@ -334,14 +335,21 @@ export function connectionTarget(uri?: vscode.Uri): ConnectionTarget {
334
335
? vscode . window . activeTextEditor . document . uri
335
336
: undefined ;
336
337
if ( uri ) {
337
- if ( notIsfs ( uri ) ) {
338
- const folder = vscode . workspace . getWorkspaceFolder ( uri ) ;
338
+ if ( uri . scheme == OBJECTSCRIPT_FILE_SCHEMA ) {
339
+ // For objectscript:// files the authority is the workspace folder name
340
+ result . apiTarget = uri ;
341
+ result . configName = uri . authority ;
342
+ } else if ( notIsfs ( uri ) ) {
343
+ const folder = vscode . workspace . getWorkspaceFolder (
344
+ // For XML preview files the fragment contains the URI for connection purposes
345
+ uri . scheme == OBJECTSCRIPTXML_FILE_SCHEMA ? vscode . Uri . parse ( uri . fragment ) : uri
346
+ ) ;
339
347
// Active document might not be from any folder in the workspace (e.g. user's settings.json)
340
348
if ( folder ) {
341
349
result . configName = folder . name ;
342
350
result . apiTarget = result . configName ;
343
351
}
344
- } else if ( schemas . includes ( uri . scheme ) ) {
352
+ } else {
345
353
result . apiTarget = uri ;
346
354
const parts = uri . authority . split ( ":" ) ;
347
355
result . configName = parts . length === 2 ? parts [ 0 ] : uri . authority ;
@@ -390,10 +398,14 @@ export function currentWorkspaceFolder(document?: vscode.TextDocument): string {
390
398
}
391
399
392
400
export function workspaceFolderOfUri ( uri : vscode . Uri ) : string {
393
- if ( notIsfs ( uri ) ) {
394
- if ( vscode . workspace . getWorkspaceFolder ( uri ) ) {
395
- return vscode . workspace . getWorkspaceFolder ( uri ) . name ;
396
- }
401
+ if ( uri . scheme == OBJECTSCRIPT_FILE_SCHEMA ) {
402
+ // For objectscript:// files the authority is the workspace folder name
403
+ return uri . authority ;
404
+ } else if ( uri . scheme == OBJECTSCRIPTXML_FILE_SCHEMA ) {
405
+ // For XML preview files the fragment contains the URI of the original XML file
406
+ return vscode . workspace . getWorkspaceFolder ( vscode . Uri . parse ( uri . fragment ) ) ?. name ?? "" ;
407
+ } else if ( notIsfs ( uri ) ) {
408
+ return vscode . workspace . getWorkspaceFolder ( uri ) ?. name ?? "" ;
397
409
} else {
398
410
const rootUri = uri . with ( { path : "/" } ) . toString ( ) ;
399
411
const foundFolder = vscode . workspace . workspaceFolders . find (
0 commit comments