Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src-main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,21 @@ app.whenReady().then(() => {
isMigrating = false;

const commandLineOptions = parseCommandLine(process.argv);
EditorWindow.openFiles([
let filesToOpen = [
...filesQueuedToOpen,
...commandLineOptions.files
], commandLineOptions.fullscreen, process.cwd());
];

// If no files specified and resumeSession is enabled, try to open lastOpenedFile
if (
filesToOpen.length === 0 &&
settings.resumeSession &&
settings.lastOpenedFile
) {
filesToOpen = [settings.lastOpenedFile];
}

EditorWindow.openFiles(filesToOpen, commandLineOptions.fullscreen, process.cwd());

if (AbstractWindow.getAllWindows().length === 0) {
// No windows were successfully opened. Let's just quit.
Expand Down
4 changes: 4 additions & 0 deletions src-main/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
"string": "Enable spell checker",
"developer_comment": "Option in desktop settings to disable spell checking"
},
"desktop-settings.resume-session": {
"string": "Continue from the last opened file.",
"developer_comment": "Desktop settings option to enable session resuming"
},
"desktop-settings.exit-fullscreen-on-escape": {
"string": "Exit F11 fullscreen mode (not the fullscreen button in the editor) when pressing escape",
"developer_comment": "Refering to when an entire window is in fullscreen by pressing F11 or the maximize button on macOS, not the fullscreen mode you get by pressing the fullscreen button in the editor."
Expand Down
7 changes: 7 additions & 0 deletions src-main/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ class Settings {
this.data.spellchecker = spellchecker;
}

get resumeSession () {
return this.data.resumeSession !== false;
}
set resumeSession (resumeSession) {
this.data.resumeSession = resumeSession;
}

get exitFullscreenOnEscape () {
return this.data.exitFullscreenOnEscape !== false;
}
Expand Down
4 changes: 4 additions & 0 deletions src-main/windows/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ class EditorWindow extends ProjectRunningWindow {
new EditorWindow(parseOpenedFile(file, workingDirectory), fullscreen);
}
}
if (files && files.length > 0) {
settings.lastOpenedFile = files[0];
settings.save();
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src-preload/desktop-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ contextBridge.exposeInMainWorld('DesktopSettingsPreload', {
setBackgroundThrottling: (backgroundThrottling) => ipcRenderer.invoke('set-background-throttling', backgroundThrottling),
setBypassCORS: (bypassCORS) => ipcRenderer.invoke('set-bypass-cors', bypassCORS),
setSpellchecker: (spellchecker) => ipcRenderer.invoke('set-spellchecker', spellchecker),
setResumeSession: (resumeSession) => ipcRenderer.invoke('set-resume-session', resumeSession),
setExitFullscreenOnEscape: (exitFullscreenOnEscape) => ipcRenderer.invoke('set-exit-fullscreen-on-escape', exitFullscreenOnEscape),
setRichPresence: (richPresence) => ipcRenderer.invoke('set-rich-presence', richPresence),
openUserData: () => ipcRenderer.invoke('open-user-data')
Expand Down
13 changes: 13 additions & 0 deletions src-renderer/desktop-settings/desktop-settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ <h1 class="title"></h1>
document.querySelector('.spellchecker-label').textContent = strings['desktop-settings.spellchecker'];
</script>

<label>
<input type="checkbox" class="resume-session-checkbox" autocomplete="off">
<span class="resume-session-label"></span>
</label>
<script>
const resumeSession = document.querySelector('.resume-session-checkbox');
resumeSession.onchange = () => {
DesktopSettingsPreload.setResumeSession(resumeSession.checked);
};
resumeSession.checked = settings.resumeSession;
document.querySelector('.resume-session-label').textContent = strings['desktop-settings.resume-session'];
</script>

<label>
<input type="checkbox" class="exit-fullscreen-on-escape-checkbox" autocomplete="off">
<span class="exit-fullscreen-on-escape-label"></span>
Expand Down