If working on a saved or opened file, use its filename as default for Save As

This commit is contained in:
Skyler Lehmkuhl 2024-12-16 22:10:18 -05:00
parent ab7e7cd324
commit 124b811493
1 changed files with 4 additions and 2 deletions

View File

@ -2315,6 +2315,7 @@ async function save() {
} }
async function saveAs() { async function saveAs() {
const filename = filePath ? await basename(filePath) : "untitled.beam"
const path = await saveFileDialog({ const path = await saveFileDialog({
filters: [ filters: [
{ {
@ -2322,7 +2323,7 @@ async function saveAs() {
extensions: ['beam'], extensions: ['beam'],
}, },
], ],
defaultPath: await join(await documentDir(), "untitled.beam") defaultPath: await join(await documentDir(), filename)
}); });
if (path != undefined) _save(path); if (path != undefined) _save(path);
} }
@ -2364,6 +2365,7 @@ async function open() {
undoStack.push(action) undoStack.push(action)
} }
lastSaveIndex = undoStack.length - 1; lastSaveIndex = undoStack.length - 1;
filePath = path
updateUI() updateUI()
} else { } else {
await messageDialog(`File ${path} was created in a newer version of Lightningbeam and cannot be opened in this version.`, { title: 'File version mismatch', kind: 'error' }); await messageDialog(`File ${path} was created in a newer version of Lightningbeam and cannot be opened in this version.`, { title: 'File version mismatch', kind: 'error' });