Add option to reopen file from last session
This commit is contained in:
parent
666db06b78
commit
268790943f
12
src/main.js
12
src/main.js
|
|
@ -379,6 +379,7 @@ let config = {
|
|||
recentFiles: [],
|
||||
scrollSpeed: 1,
|
||||
debug: false,
|
||||
reopenLastSession: false
|
||||
};
|
||||
|
||||
function getShortcut(shortcut) {
|
||||
|
|
@ -421,13 +422,8 @@ 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
|
||||
|
|
@ -6730,8 +6726,12 @@ 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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue