@@ -303,6 +303,8 @@ export async function pickDocument(api: AtelierAPI, prompt?: string): Promise<st
303303 return new Promise < string > ( ( resolve ) => {
304304 const quickPick = vscode . window . createQuickPick < DocumentPickerItem > ( ) ;
305305 quickPick . title = `${ prompt ? prompt : "Select a document" } in namespace '${ api . ns } ' on server '${ api . serverId } '` ;
306+ quickPick . prompt =
307+ "Select a package or folder to view its contents. Selecting '..' shows the previous level's contents. You may also type a full document name into the filter box and press 'Enter' to select that document." ;
306308 quickPick . ignoreFocusOut = true ;
307309 quickPick . buttons = [
308310 {
@@ -383,21 +385,47 @@ export async function pickDocument(api: AtelierAPI, prompt?: string): Promise<st
383385 doc . startsWith ( "%" ) && doc . split ( "." ) . length == 2 && doc . slice ( - 4 ) == ".cls"
384386 ? `%Library.${ doc . slice ( 1 ) } `
385387 : doc ;
386- api
387- . headDoc ( doc )
388- . then ( ( ) => resolve ( doc ) )
389- . catch ( ( error ) => {
390- vscode . window . showErrorMessage (
391- error ?. statusCode == 400
392- ? `'${ doc } ' is an invalid document name.`
393- : error ?. statusCode == 404
394- ? `Document '${ doc } ' does not exist.`
395- : `Internal Server Error encountered trying to validate document '${ doc } '.` ,
396- "Dismiss"
397- ) ;
398- resolve ( undefined ) ;
399- } )
400- . finally ( ( ) => quickPick . hide ( ) ) ;
388+ if ( doc . endsWith ( ".cls" ) ) {
389+ // Use StudioOpenDialog for classes so we don't expose Hidden ones
390+ api
391+ . actionQuery ( "SELECT Name, Type FROM %Library.RoutineMgr_StudioOpenDialog(?,1,1,1,1,0,1,,0,1)" , [ doc ] )
392+ . then ( ( data ) => {
393+ if ( data . result . content ?. length ) {
394+ // doc is the name of a class that exists and is visible by the user
395+ resolve ( doc ) ;
396+ } else {
397+ vscode . window . showErrorMessage (
398+ `Class '${ doc . slice ( 0 , - 4 ) } ' does not exist, or is Hidden.` ,
399+ "Dismiss"
400+ ) ;
401+ resolve ( undefined ) ;
402+ }
403+ } )
404+ . catch ( ( ) => {
405+ vscode . window . showErrorMessage (
406+ `Internal Server Error encountered trying to validate class name '${ doc . slice ( 0 , - 4 ) } '.` ,
407+ "Dismiss"
408+ ) ;
409+ resolve ( undefined ) ;
410+ } )
411+ . finally ( ( ) => quickPick . hide ( ) ) ;
412+ } else {
413+ api
414+ . headDoc ( doc )
415+ . then ( ( ) => resolve ( doc ) )
416+ . catch ( ( error ) => {
417+ vscode . window . showErrorMessage (
418+ error ?. statusCode == 400
419+ ? `'${ doc } ' is an invalid document name.`
420+ : error ?. statusCode == 404
421+ ? `Document '${ doc } ' does not exist.`
422+ : `Internal Server Error encountered trying to validate document '${ doc } '.` ,
423+ "Dismiss"
424+ ) ;
425+ resolve ( undefined ) ;
426+ } )
427+ . finally ( ( ) => quickPick . hide ( ) ) ;
428+ }
401429 } else {
402430 // The document name came from an item so no validation is required
403431 resolve ( doc ) ;
0 commit comments