diff --git a/src/commands/compile.ts b/src/commands/compile.ts index 41fc64a5..ec461310 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -812,25 +812,22 @@ interface XMLQuickPickItem extends vscode.QuickPickItem { export async function importXMLFiles(): Promise { try { - // Use the server connection from the active document if possible - let connectionUri = currentFile()?.uri; - if (!connectionUri) { - // Use the server connection from a workspace folder - const workspaceFolders = vscode.workspace.workspaceFolders || []; - if (workspaceFolders.length == 0) { - vscode.window.showErrorMessage("'Import XML Files...' command requires an open workspace.", "Dismiss"); - } else if (workspaceFolders.length == 1) { - // Use the current connection - connectionUri = workspaceFolders[0].uri; - } else { - // Pick from the workspace folders - connectionUri = ( - await vscode.window.showWorkspaceFolderPick({ - ignoreFocusOut: true, - placeHolder: "Pick the workspace folder to get server connection information from", - }) - )?.uri; - } + // Use the server connection from a workspace folder + let connectionUri: vscode.Uri; + const workspaceFolders = vscode.workspace.workspaceFolders || []; + if (workspaceFolders.length == 0) { + vscode.window.showErrorMessage("'Import XML Files...' command requires an open workspace.", "Dismiss"); + } else if (workspaceFolders.length == 1) { + // Use the current connection + connectionUri = workspaceFolders[0].uri; + } else { + // Pick from the workspace folders + connectionUri = ( + await vscode.window.showWorkspaceFolderPick({ + ignoreFocusOut: true, + placeHolder: "Pick the workspace folder to get server connection information from", + }) + )?.uri; } if (connectionUri) { const api = new AtelierAPI(connectionUri); diff --git a/src/commands/export.ts b/src/commands/export.ts index f03e3e70..00e8b994 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -385,28 +385,25 @@ export async function exportCurrentFile(): Promise { export async function exportDocumentsToXMLFile(): Promise { try { - // Use the server connection from the active document if possible - let connectionUri = currentFile()?.uri; - if (!connectionUri) { - // Use the server connection from a workspace folder - const workspaceFolders = vscode.workspace.workspaceFolders || []; - if (workspaceFolders.length == 0) { - vscode.window.showErrorMessage( - "'Export Documents to XML File...' command requires an open workspace.", - "Dismiss" - ); - } else if (workspaceFolders.length == 1) { - // Use the current connection - connectionUri = workspaceFolders[0].uri; - } else { - // Pick from the workspace folders - connectionUri = ( - await vscode.window.showWorkspaceFolderPick({ - ignoreFocusOut: true, - placeHolder: "Pick the workspace folder to get server connection information from", - }) - )?.uri; - } + // Use the server connection from a workspace folder + let connectionUri: vscode.Uri; + const workspaceFolders = vscode.workspace.workspaceFolders || []; + if (workspaceFolders.length == 0) { + vscode.window.showErrorMessage( + "'Export Documents to XML File...' command requires an open workspace.", + "Dismiss" + ); + } else if (workspaceFolders.length == 1) { + // Use the current connection + connectionUri = workspaceFolders[0].uri; + } else { + // Pick from the workspace folders + connectionUri = ( + await vscode.window.showWorkspaceFolderPick({ + ignoreFocusOut: true, + placeHolder: "Pick the workspace folder to get server connection information from", + }) + )?.uri; } if (connectionUri) { const api = new AtelierAPI(connectionUri);