@@ -16,7 +16,6 @@ import {
1616 RateLimiter ,
1717 replaceFile ,
1818 stringifyError ,
19- uriOfWorkspaceFolder ,
2019 workspaceFolderOfUri ,
2120} from "../utils" ;
2221import { pickDocuments } from "../utils/documentPicker" ;
@@ -127,24 +126,24 @@ async function exportFile(wsFolderUri: vscode.Uri, namespace: string, name: stri
127126 }
128127}
129128
130- export async function exportList ( files : string [ ] , workspaceFolder : string , namespace : string ) : Promise < any > {
129+ export async function exportList ( files : string [ ] , wsFolder : vscode . WorkspaceFolder , namespace ? : string ) : Promise < any > {
131130 if ( ! files || ! files . length ) {
132131 vscode . window . showWarningMessage ( "No documents to export." , "Dismiss" ) ;
133132 return ;
134133 }
135- const wsFolderUri = uriOfWorkspaceFolder ( workspaceFolder ) ;
136- if ( ! workspaceFolder || ! wsFolderUri ) return ;
137- if ( ! vscode . workspace . fs . isWritableFileSystem ( wsFolderUri . scheme ) ) {
138- vscode . window . showErrorMessage ( `Cannot export to read-only file system '${ wsFolderUri . scheme } '.` , "Dismiss" ) ;
134+ if ( ! wsFolder ) return ;
135+ if ( ! vscode . workspace . fs . isWritableFileSystem ( wsFolder . uri . scheme ) ) {
136+ vscode . window . showErrorMessage ( `Cannot export to read-only file system '${ wsFolder . uri . scheme } '.` , "Dismiss" ) ;
139137 return ;
140138 }
141- if ( ! new AtelierAPI ( wsFolderUri ) . active ) {
139+ const api = new AtelierAPI ( wsFolder . uri ) ;
140+ if ( ! api . active ) {
142141 vscode . window . showErrorMessage ( "Exporting documents requires an active server connection." , "Dismiss" ) ;
143142 return ;
144143 }
145144
146- const { atelier, folder, addCategory, map } = config ( "export" , workspaceFolder ) ;
147- const root = wsFolderUri . fsPath + ( folder . length ? path . sep + folder : "" ) ;
145+ const { atelier, folder, addCategory, map } = config ( "export" , wsFolder . name ) ;
146+ const root = wsFolder . uri . fsPath + ( folder . length ? path . sep + folder : "" ) ;
148147 outputChannel . show ( true ) ;
149148 const rateLimiter = new RateLimiter ( 50 ) ;
150149 return vscode . window . withProgress (
@@ -157,7 +156,7 @@ export async function exportList(files: string[], workspaceFolder: string, names
157156 Promise . allSettled < void > (
158157 files . map ( ( file ) =>
159158 rateLimiter . call ( ( ) =>
160- exportFile ( wsFolderUri , namespace , file , getFileName ( root , file , atelier , addCategory , map ) )
159+ exportFile ( wsFolder . uri , namespace ?? api . ns , file , getFileName ( root , file , atelier , addCategory , map ) )
161160 )
162161 )
163162 )
@@ -223,24 +222,21 @@ export async function exportAll(): Promise<any> {
223222 if ( ! files ?. length ) return ;
224223 await exportList (
225224 files . map ( ( file ) => file . label ) ,
226- wsFolder . name ,
227- api . ns
225+ wsFolder
228226 ) ;
229227 } catch ( error ) {
230228 handleError ( error , "Error executing 'Export Code from Server...' command." ) ;
231229 }
232230}
233231
234232export async function exportExplorerItems ( nodes : NodeBase [ ] ) : Promise < any > {
235- const node = nodes [ 0 ] ;
236- const nodeNs = node . namespace . toUpperCase ( ) ;
237- const origNamespace = config ( "conn" , node . workspaceFolder ) . ns ?. toUpperCase ( ) ;
238- if ( origNamespace ?. toUpperCase ( ) != node . namespace . toUpperCase ( ) ) {
233+ const { wsFolder, namespace } = nodes [ 0 ] ;
234+ if ( namespace ) {
239235 const answer = await vscode . window . showWarningMessage (
240236 `
241- You are about to export from namespace ${ nodeNs } .
237+ You are about to export from namespace ${ namespace } .
242238
243- Future edits to the file(s) in your local workspace will be saved and compiled in the primary namespace of your workspace root, ${ origNamespace } , not the namespace from which you originally exported.
239+ Future edits to the file(s) in your local workspace will be saved and compiled in the primary namespace of your workspace root, ${ new AtelierAPI ( wsFolder . uri ) . ns } , not the namespace from which you originally exported.
244240
245241Would you like to continue?` ,
246242 {
@@ -252,9 +248,9 @@ Would you like to continue?`,
252248 return ;
253249 }
254250 }
255- return Promise . all ( nodes . map ( ( node ) => node . getItems4Export ( ) ) )
251+ return Promise . all ( nodes . map ( ( node ) => node . getItemsForExport ( ) ) )
256252 . then ( ( items ) => {
257- return exportList ( items . flat ( ) , node . workspaceFolder , nodeNs ) . then ( ( ) => explorerProvider . refresh ( ) ) ;
253+ return exportList ( items . flat ( ) , wsFolder , namespace ) . then ( ( ) => explorerProvider . refresh ( ) ) ;
258254 } )
259255 . catch ( ( error ) => {
260256 handleError ( error , "Error exporting Explorer items." ) ;
@@ -272,8 +268,7 @@ export async function exportCurrentFile(): Promise<any> {
272268 // Only export files opened from the explorer
273269 return ;
274270 }
275- const api = new AtelierAPI ( openDoc . uri ) ;
276- return exportList ( [ currentFile ( openDoc ) . name ] , api . configName , api . config . ns ) ;
271+ return exportList ( [ currentFile ( openDoc ) . name ] , vscode . workspace . getWorkspaceFolder ( openDoc . uri ) ) ;
277272}
278273
279274export async function exportDocumentsToXMLFile ( ) : Promise < void > {
0 commit comments