From 6359f43ddad02ab7b8b7490d85a686404f119bda Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Mon, 16 Mar 2026 07:04:57 -0400 Subject: [PATCH] Disallow opening `Hidden` classes using `Open InterSystems Document...` command --- src/utils/documentPicker.ts | 58 +++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/src/utils/documentPicker.ts b/src/utils/documentPicker.ts index fb1683bc..8ea0d09d 100644 --- a/src/utils/documentPicker.ts +++ b/src/utils/documentPicker.ts @@ -303,6 +303,8 @@ export async function pickDocument(api: AtelierAPI, prompt?: string): Promise((resolve) => { const quickPick = vscode.window.createQuickPick(); quickPick.title = `${prompt ? prompt : "Select a document"} in namespace '${api.ns}' on server '${api.serverId}'`; + 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.ignoreFocusOut = true; quickPick.buttons = [ { @@ -383,21 +385,47 @@ export async function pickDocument(api: AtelierAPI, prompt?: string): Promise 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);