Skip to content

Commit

Permalink
XML Import/Export commands shouldn't assume a server connection in a …
Browse files Browse the repository at this point in the history
…multi-root workspace (#1387)
  • Loading branch information
isc-bsaviano committed Jun 26, 2024
1 parent ac4929d commit 5cfc9ec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 41 deletions.
35 changes: 16 additions & 19 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,25 +812,22 @@ interface XMLQuickPickItem extends vscode.QuickPickItem {

export async function importXMLFiles(): Promise<any> {
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);
Expand Down
41 changes: 19 additions & 22 deletions src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,28 +385,25 @@ export async function exportCurrentFile(): Promise<any> {

export async function exportDocumentsToXMLFile(): Promise<void> {
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);
Expand Down

0 comments on commit 5cfc9ec

Please sign in to comment.