This commit is contained in:
2025-10-15 12:56:15 +02:00
parent 008d5cb661
commit 1ead074e21
4 changed files with 92 additions and 75 deletions

View File

@ -133,10 +133,10 @@
projectEditor.setContent(value);
}
function handleNewEmptyFile() {
async function handleNewEmptyFile() {
const emptyTemplate = templateRegistry.getEmpty();
const result = projectEditor.requestSwitch(() =>
projectEditor.createNew(emptyTemplate.content),
const result = projectEditor.requestSwitch(async () =>
await projectEditor.createNew(emptyTemplate.content, emptyTemplate.mode),
);
if (result === "confirm-unsaved") {
@ -148,11 +148,11 @@
uiState.showTemplateDialog();
}
function handleTemplateSelect(template: CsoundTemplate) {
async function handleTemplateSelect(template: CsoundTemplate) {
uiState.hideTemplateDialog();
const result = projectEditor.requestSwitch(() =>
projectEditor.createNew(template.content),
const result = projectEditor.requestSwitch(async () =>
await projectEditor.createNew(template.content, template.mode),
);
if (result === "confirm-unsaved") {
@ -181,11 +181,6 @@
}
async function handleSave() {
if (projectEditor.isNewUnsavedBuffer) {
uiState.showSaveAsDialog();
return;
}
await projectEditor.save();
}
@ -208,14 +203,8 @@
}
async function handleSwitchSave() {
const result = await projectEditor.confirmSaveAndSwitch();
if (result === "show-save-as") {
uiState.hideUnsavedChangesDialog();
uiState.showSaveAsDialog();
} else {
uiState.hideUnsavedChangesDialog();
}
await projectEditor.confirmSaveAndSwitch();
uiState.hideUnsavedChangesDialog();
}
function handleSwitchDiscard() {