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: [],
|
recentFiles: [],
|
||||||
scrollSpeed: 1,
|
scrollSpeed: 1,
|
||||||
debug: false,
|
debug: false,
|
||||||
|
reopenLastSession: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function getShortcut(shortcut) {
|
function getShortcut(shortcut) {
|
||||||
|
|
@ -421,13 +422,8 @@ async function saveConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addRecentFile(filePath) {
|
async function addRecentFile(filePath) {
|
||||||
if (!config.recentFiles.includes(filePath)) {
|
config.recentFiles = [filePath, ...config.recentFiles.filter(file => file !== filePath)].slice(0, 10);
|
||||||
config.recentFiles.unshift(filePath);
|
|
||||||
if (config.recentFiles.length > 10) {
|
|
||||||
config.recentFiles = config.recentFiles.slice(0, 10);
|
|
||||||
}
|
|
||||||
await saveConfig(config);
|
await saveConfig(config);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pointers to all objects
|
// Pointers to all objects
|
||||||
|
|
@ -6730,8 +6726,12 @@ async function startup() {
|
||||||
await loadConfig();
|
await loadConfig();
|
||||||
createNewFileDialog(_newFile, _open, config);
|
createNewFileDialog(_newFile, _open, config);
|
||||||
if (!window.openedFiles?.length) {
|
if (!window.openedFiles?.length) {
|
||||||
|
if (config.reopenLastSession && config.recentFiles?.length) {
|
||||||
|
_open(config.recentFiles[0])
|
||||||
|
} else {
|
||||||
showNewFileDialog(config);
|
showNewFileDialog(config);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue