diff --git a/src/utils/documentPicker.ts b/src/utils/documentPicker.ts index e0ad0327..3f8a4f77 100644 --- a/src/utils/documentPicker.ts +++ b/src/utils/documentPicker.ts @@ -311,6 +311,8 @@ export async function pickDocument( return new Promise((resolve) => { const quickPick = vscode.window.createQuickPick(); + quickPick.prompt = + "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."; quickPick.title = `${prompt ? prompt : "Select a document"} ${numberOfSteps ? `(${step}/${numberOfSteps})` : `in namespace '${api.ns}' on server '${api.serverId}'`}`; quickPick.ignoreFocusOut = true; quickPick.buttons = [ @@ -402,21 +404,47 @@ export async function pickDocument( doc.startsWith("%") && doc.split(".").length == 2 && doc.slice(-4) == ".cls" ? `%Library.${doc.slice(1)}` : doc; - api - .headDoc(doc) - .then(() => resolve(doc)) - .catch((error) => { - vscode.window.showErrorMessage( - error?.statusCode == 400 - ? `'${doc}' is an invalid document name.` - : error?.statusCode == 404 - ? `Document '${doc}' does not exist.` - : `Internal Server Error encountered trying to validate document '${doc}'.`, - "Dismiss" - ); - resolve(undefined); - }) - .finally(() => quickPick.hide()); + if (doc.endsWith(".cls")) { + // Use StudioOpenDialog for classes so we don't expose Hidden ones + api + .actionQuery("SELECT Name, Type FROM %Library.RoutineMgr_StudioOpenDialog(?,1,1,1,1,0,1,,0,1)", [doc]) + .then((data) => { + if (data.result.content?.length) { + // doc is the name of a class that exists and is visible by the user + resolve(doc); + } else { + vscode.window.showErrorMessage( + `Class '${doc.slice(0, -4)}' does not exist, or is Hidden.`, + "Dismiss" + ); + resolve(undefined); + } + }) + .catch(() => { + vscode.window.showErrorMessage( + `Internal Server Error encountered trying to validate class name '${doc.slice(0, -4)}'.`, + "Dismiss" + ); + resolve(undefined); + }) + .finally(() => quickPick.hide()); + } else { + api + .headDoc(doc) + .then(() => resolve(doc)) + .catch((error) => { + vscode.window.showErrorMessage( + error?.statusCode == 400 + ? `'${doc}' is an invalid document name.` + : error?.statusCode == 404 + ? `Document '${doc}' does not exist.` + : `Internal Server Error encountered trying to validate document '${doc}'.`, + "Dismiss" + ); + resolve(undefined); + }) + .finally(() => quickPick.hide()); + } } else { // The document name came from an item so no validation is required resolve(doc);