@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22import path = require( "path" ) ;
33import { config , OBJECTSCRIPTXML_FILE_SCHEMA , xmlContentProvider } from "../extension" ;
44import { AtelierAPI } from "../api" ;
5- import { fileExists , handleError , notIsfs , outputChannel } from "../utils" ;
5+ import { fileExists , getWsFolder , handleError , notIsfs , outputChannel } from "../utils" ;
66import { getFileName } from "./export" ;
77
88const exportHeader = / ^ \s * < E x p o r t g e n e r a t o r = " ( C a c h e | I R I S ) " v e r s i o n = " \d + " / ;
@@ -33,7 +33,6 @@ export async function previewXMLAsUDL(textEditor: vscode.TextEditor, auto = fals
3333 } ) ,
3434 {
3535 canPickMany : true ,
36- ignoreFocusOut : true ,
3736 title : "Select the documents to preview" ,
3837 }
3938 ) ;
@@ -96,29 +95,17 @@ export async function extractXMLFileContents(xmlUri?: vscode.Uri): Promise<void>
9695 if ( xmlUri ) {
9796 wsFolder = vscode . workspace . getWorkspaceFolder ( xmlUri ) ;
9897 } else {
99- // Can only run this command on non-isfs folders with an active server connection
100- const options = vscode . workspace . workspaceFolders . filter ( ( f ) => notIsfs ( f . uri ) && new AtelierAPI ( f . uri ) . active ) ;
101- if ( options . length == 0 ) {
102- vscode . window . showErrorMessage (
103- "'Extract Documents from XML File...' command requires a non-isfs workspace folder with an active server connection." ,
104- "Dismiss"
105- ) ;
98+ // Use the server connection from a workspace folder
99+ wsFolder = await getWsFolder ( "Pick the workspace folder to run the command in" , false , false , true , true ) ;
100+ if ( ! wsFolder ) {
101+ if ( wsFolder === undefined ) {
102+ // Strict equality needed because undefined == null
103+ vscode . window . showErrorMessage (
104+ "'Extract Documents from XML File...' command requires a non-isfs workspace folder with an active server connection." ,
105+ "Dismiss"
106+ ) ;
107+ }
106108 return ;
107- } else if ( options . length == 1 ) {
108- wsFolder = options [ 0 ] ;
109- } else {
110- // Prompt the user to select a workspace folder
111- wsFolder = (
112- await vscode . window . showQuickPick (
113- options . map ( ( f ) => {
114- return { label : f . name , wf : f } ;
115- } ) ,
116- {
117- ignoreFocusOut : true ,
118- title : "Pick the workspace folder to run the command in" ,
119- }
120- )
121- ) ?. wf ;
122109 }
123110 }
124111 if ( ! wsFolder ) return ;
0 commit comments