@@ -11,6 +11,7 @@ import {
1111} from "../extension" ;
1212import { cspAppsForUri , handleError , notIsfs } from "../utils" ;
1313import { pickProject } from "./project" ;
14+ import { isfsConfig , IsfsUriParam } from "../utils/FileProviderUtil" ;
1415
1516/**
1617 * @param message The prefix of the message to show when the server manager API can't be found.
@@ -143,9 +144,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
143144 return ;
144145 }
145146 // Generate the name
146- const params = new URLSearchParams ( uri . query ) ;
147- const project = params . get ( "project" ) ;
148- const csp = params . has ( "csp" ) ;
147+ const { csp, project } = isfsConfig ( uri ) ;
149148 const name = `${ project ? `${ project } - ${ serverName } :${ namespace } ` : ! csp ? `${ serverName } :${ namespace } ` : [ "" , "/" ] . includes ( uri . path ) ? `${ serverName } :${ namespace } web files` : `${ serverName } (${ uri . path } )` } ${
150149 scheme == FILESYSTEM_READONLY_SCHEMA && ! project ? " (read-only)" : ""
151150 } `;
@@ -188,7 +187,7 @@ export async function getServerManagerApi(): Promise<any> {
188187/** Prompt the user to fill in the `path` and `query` of `uri`. */
189188async function modifyWsFolderUri ( uri : vscode . Uri ) : Promise < vscode . Uri | undefined > {
190189 if ( notIsfs ( uri ) ) return ;
191- const params = new URLSearchParams ( uri . query ) ;
190+ const { project , csp , system , generated , mapped , filter } = isfsConfig ( uri ) ;
192191 const api = new AtelierAPI ( uri ) ;
193192
194193 // Prompt the user for the files to show
@@ -211,9 +210,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
211210 detail : "Choose an existing project, or create a new one." ,
212211 } ,
213212 ] ;
214- quickPick . activeItems = [
215- params . has ( "project" ) ? quickPick . items [ 2 ] : params . has ( "csp" ) ? quickPick . items [ 1 ] : quickPick . items [ 0 ] ,
216- ] ;
213+ quickPick . activeItems = [ project ? quickPick . items [ 2 ] : csp ? quickPick . items [ 1 ] : quickPick . items [ 0 ] ] ;
217214
218215 quickPick . onDidChangeSelection ( ( items ) => {
219216 switch ( items [ 0 ] . label ) {
@@ -258,7 +255,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
258255 // Catch handler reported the error already
259256 return ;
260257 } else if ( cspApps . length == 0 ) {
261- vscode . window . showWarningMessage ( `No web applications are configured to use namespace ${ api . ns } .` , "Dismiss" ) ;
258+ vscode . window . showWarningMessage ( `No web applications are configured in namespace ${ api . ns } .` , "Dismiss" ) ;
262259 return ;
263260 }
264261 }
@@ -292,43 +289,43 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
292289 if ( ! newPath ) {
293290 return ;
294291 }
295- newParams = "csp" ;
292+ newParams = IsfsUriParam . CSP ;
296293 } else if ( filterType == "project" ) {
297294 // Prompt for project
298295 const project = await pickProject ( new AtelierAPI ( uri ) ) ;
299296 if ( ! project ) {
300297 return ;
301298 }
302- newParams = `project =${ project } ` ;
299+ newParams = `${ IsfsUriParam . Project } =${ project } ` ;
303300 } else {
304301 // Prompt the user for other query parameters
305302 const items = [
306303 {
307304 label : "$(filter) Filter" ,
308305 detail : "Comma-delimited list of search options, e.g. '*.cls,*.inc,*.mac,*.int'" ,
309- picked : params . has ( " filter" ) ,
310- value : "filter" ,
306+ picked : filter != "" ,
307+ value : IsfsUriParam . Filter ,
311308 } ,
312309 {
313310 label : "$(server-process) Show Generated" ,
314311 detail : "Also show files tagged as generated, e.g. by compilation." ,
315- picked : params . has ( " generated" ) ,
316- value : "generated" ,
312+ picked : generated ,
313+ value : IsfsUriParam . Generated ,
317314 } ,
318315 {
319316 label : "$(references) Hide Mapped" ,
320317 detail : `Hide files that are mapped into ${ api . ns } from another code database.` ,
321- picked : params . has ( " mapped" ) ,
322- value : "mapped" ,
318+ picked : ! mapped ,
319+ value : IsfsUriParam . Mapped ,
323320 } ,
324321 ] ;
325322 if ( api . ns != "%SYS" ) {
326323 // Only show system item for non-%SYS namespaces
327324 items . push ( {
328325 label : "$(library) Show System" ,
329326 detail : "Also show '%' items and INFORMATION.SCHEMA items." ,
330- picked : params . has ( " system" ) ,
331- value : "system" ,
327+ picked : system ,
328+ value : IsfsUriParam . System ,
332329 } ) ;
333330 }
334331 const otherParams = await vscode . window . showQuickPick ( items , {
@@ -340,37 +337,29 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
340337 return ;
341338 }
342339 // Build the new query parameter string
343- params . delete ( "csp" ) ;
344- params . delete ( "project" ) ;
345- params . delete ( "filter" ) ;
346- params . delete ( "flat" ) ;
347- params . delete ( "generated" ) ;
348- params . delete ( "mapped" ) ;
349- params . delete ( "system" ) ;
350- params . delete ( "type" ) ;
340+ const params = new URLSearchParams ( ) ;
351341 for ( const otherParam of otherParams ) {
352342 switch ( otherParam . value ) {
353- case "filter" : {
343+ case IsfsUriParam . Filter : {
354344 // Prompt for filter
355- const filter = await vscode . window . showInputBox ( {
345+ const newFilter = await vscode . window . showInputBox ( {
356346 title : "Enter a filter string." ,
357347 ignoreFocusOut : true ,
358- value : params . get ( " filter" ) ,
348+ value : filter ,
359349 placeHolder : "*.cls,*.inc,*.mac,*.int" ,
360350 prompt :
361351 "Patterns are comma-delimited and may contain both * (zero or more characters) and ? (a single character) as wildcards. To exclude items, prefix the pattern with a single quote." ,
362352 } ) ;
363- if ( filter && filter . length ) {
364- params . set ( otherParam . value , filter ) ;
353+ if ( newFilter && newFilter . length ) {
354+ params . set ( otherParam . value , newFilter ) ;
365355 }
366356 break ;
367357 }
368- case "generated" :
369- case "system" :
370- params . set ( otherParam . value , "1" ) ;
371- break ;
372- case "mapped" :
358+ case IsfsUriParam . Mapped :
373359 params . set ( otherParam . value , "0" ) ;
360+ break ;
361+ default : // system and generated
362+ params . set ( otherParam . value , "1" ) ;
374363 }
375364 }
376365 newParams = params . toString ( ) ;
0 commit comments