Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions src/utils/documentPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ export async function pickDocument(

return new Promise<string>((resolve) => {
const quickPick = vscode.window.createQuickPick<DocumentPickerItem>();
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 = [
Expand Down Expand Up @@ -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);
Expand Down
Loading