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
49 changes: 44 additions & 5 deletions src/commands/newFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,50 @@ ClassMethod %OnDashboardAction(pAction As %String, pContext As %ZEN.proxyObject)
clsUri = DocumentContentProvider.getUri(`${cls}.cls`, undefined, undefined, undefined, wsFolder.uri);
} else {
// Ask the user for the URI
clsUri = await vscode.window.showSaveDialog({
defaultUri: getLocalUri(cls, wsFolder), // Use the export settings to determine the default URI
filters: {
Classes: ["cls"],
},
const localUri = getLocalUri(cls, wsFolder);
clsUri = await new Promise<vscode.Uri>((resolve) => {
const inputBox = vscode.window.createInputBox();
inputBox.ignoreFocusOut = true;
inputBox.buttons = [{ iconPath: new vscode.ThemeIcon("save-as"), tooltip: "Show 'Save As' dialog" }];
inputBox.prompt = `The path is relative to the workspace folder root (${wsFolder.uri.toString(true)}). Intermediate folders that do not exist will be created. Click the 'Save As' icon to open the standard save dialog instead.`;
inputBox.title = "Enter a file path for the new class";
inputBox.value = localUri.path.slice(wsFolder.uri.path.length);
inputBox.valueSelection = [inputBox.value.length, inputBox.value.length];
let showingSave = false;
inputBox.onDidTriggerButton(() => {
// User wants to use the save dialog
showingSave = true;
inputBox.hide();
vscode.window
.showSaveDialog({
defaultUri: localUri,
filters: {
Classes: ["cls"],
},
})
.then(
(u) => resolve(u),
() => resolve(undefined)
);
});
inputBox.onDidAccept(() => {
if (typeof inputBox.validationMessage != "string") {
resolve(
wsFolder.uri.with({
path: `${wsFolder.uri.path}${!wsFolder.uri.path.endsWith("/") ? "/" : ""}${inputBox.value.replace(/^\/+/, "")}`,
})
);
inputBox.hide();
}
});
inputBox.onDidHide(() => {
if (!showingSave) resolve(undefined);
inputBox.dispose();
});
inputBox.onDidChangeValue((value) => {
inputBox.validationMessage = value.endsWith(".cls") ? undefined : "File extension must be .cls";
});
inputBox.show();
});
}

Expand Down