Add option to reopen file from last session

This commit is contained in:
Skyler Lehmkuhl 2025-01-18 03:32:53 -05:00
parent 666db06b78
commit 268790943f
1 changed files with 8 additions and 8 deletions

View File

@ -379,6 +379,7 @@ let config = {
recentFiles: [],
scrollSpeed: 1,
debug: false,
reopenLastSession: false
};
function getShortcut(shortcut) {
@ -421,14 +422,9 @@ async function saveConfig() {
}
async function addRecentFile(filePath) {
if (!config.recentFiles.includes(filePath)) {
config.recentFiles.unshift(filePath);
if (config.recentFiles.length > 10) {
config.recentFiles = config.recentFiles.slice(0, 10);
}
config.recentFiles = [filePath, ...config.recentFiles.filter(file => file !== filePath)].slice(0, 10);
await saveConfig(config);
}
}
// Pointers to all objects
let pointerList = {};
@ -6730,9 +6726,13 @@ async function startup() {
await loadConfig();
createNewFileDialog(_newFile, _open, config);
if (!window.openedFiles?.length) {
if (config.reopenLastSession && config.recentFiles?.length) {
_open(config.recentFiles[0])
} else {
showNewFileDialog(config);
}
}
}
startup();