Skip to content
Merged
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
3 changes: 2 additions & 1 deletion app/main/helpers/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function ensureSettingsJson() {
"devMode": false,
"splashScreen": true,
"uiScale": 1,
"language": "en"
"language": "en",
"restoreFolder": true
},
"editor": {
"smoothScroll": true
Expand Down
15 changes: 15 additions & 0 deletions app/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ document.addEventListener("DOMContentLoaded", async () => {
ExplorerSidebar.toggleWidth()
})

// restore last folder on startup
if (settings?.app?.restoreFolder !== false && settings?.app?.lastFolder) {
const lastFolder = settings.app.lastFolder
try {
await window.electron.readDirTree(lastFolder, { maxDepth: 0 })
openFolder({
pathRoot: lastFolder,
filesPanel: filesPanel,
addToHistory: addToHistory,
pathContext: pathContext,
settings: settings
})
} catch (e) {}
}

// Main

if (localData.nonAccountMode) {
Expand Down
1 change: 1 addition & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ body.explorer-resizing {
.explorer-elements .folder-icon {
width: 15px;
flex: 0 0 auto;
z-index: 1;
}
.explorer-elements .dir {
display: flex;
Expand Down
2 changes: 2 additions & 0 deletions assets/js/explorerTree/handlers/openFolderHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export async function openFolder({ pathRoot, filesPanel, addToHistory, pathConte
}
);

window.electron.setSettings({ app: { lastFolder: pathRoot } })

initializeFolderToggle(filesPanel, { pathContext, settings });
initializeExplorerContextMenu(filesPanel, { tabsByPath, recentlyClosed, pathContext, settings });

Expand Down
2 changes: 2 additions & 0 deletions assets/js/explorerTree/tabHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,13 @@ export async function openTab(path, content, extension, name, pathContext, isNew

if (cached) {
editor.setValue(cached.content ?? "", -1);
editor.session.getUndoManager().reset();
setErrors(editor.getSession().getAnnotations())
if (cached.cursor) editor.selection.moveTo(cached.cursor.row, cached.cursor.column);
if (typeof cached.scrollTop === "number") editor.session.setScrollTop(cached.scrollTop);
} else {
editor.setValue(content ?? "", -1);
editor.session.getUndoManager().reset();
setErrors(editor.getSession().getAnnotations())
}

Expand Down
6 changes: 6 additions & 0 deletions assets/js/modals/settingsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export async function getSettingsModal({ platform }) {
description: lgls("application.boldFont.description"),
id: "setting_boldFont"
},
{
type: "switch",
title: lgls("application.restoreFolder.title"),
description: lgls("application.restoreFolder.description"),
id: "setting_restoreFolder"
},
{
type: "placeholder",
title: lgls("application.theme.title"),
Expand Down
14 changes: 14 additions & 0 deletions assets/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function handleSettings(settingsObject) {
uiScale: document.querySelector("#setting_uiScale"),

coloredTabs: document.querySelector("#setting_coloredTabs"),
restoreFolder: document.querySelector("#setting_restoreFolder"),
}
)

Expand Down Expand Up @@ -101,6 +102,11 @@ export async function handleSettings(settingsObject) {
Setting.coloredTabs(t.checked)
})

settingsSelectors.restoreFolder.addEventListener("click", (e) => {
let t = e.target
Setting.restoreFolder(t.checked)
})

settingsSelectors.editorTextSize.addEventListener("change", (e) => {
Setting.editorTextSize(e.target.value)
})
Expand Down Expand Up @@ -223,6 +229,7 @@ export async function handleSettings(settingsObject) {
if("reduceMotion" in settingsObject.app) Setting.reduceMotion(settingsObject.app.reduceMotion, false)
if("uiScale" in settingsObject.app) Setting.uiScale(settingsObject.app.uiScale, false, false)
if("language" in settingsObject.app) Setting.language(settingsObject.app.language, false)
if("restoreFolder" in settingsObject.app) Setting.restoreFolder(settingsObject.app.restoreFolder, false)
}
}

Expand Down Expand Up @@ -395,4 +402,11 @@ export class Setting {
await window.electron.setSettings({ editor: { coloredTabs: value }})
}
}
static async restoreFolder(value, set = true) {
settingsSelectors.restoreFolder.checked = value

if(set) {
await window.electron.setSettings({ app: { restoreFolder: value }})
}
}
}
5 changes: 5 additions & 0 deletions languages/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@
"description": "Павялічвае таўшчыню шрыфту ва ўсёй праграме"
},

"restoreFolder": {
"title": "Restore last folder",
"description": "Automatically reopen the last opened folder when the app starts"
},

"theme": {
"title": "Тэма",
"description": "Змяніць тэму праграмы"
Expand Down
5 changes: 5 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
"description": "Increases font weight across the application"
},

"restoreFolder": {
"title": "Restore last folder",
"description": "Automatically reopen the last opened folder when the app starts"
},

"theme": {
"title": "Theme",
"description": "Change application theme"
Expand Down
5 changes: 5 additions & 0 deletions languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@
"description": "Zwiększa wagę czcionki w całej aplikacji"
},

"restoreFolder": {
"title": "Restore last folder",
"description": "Automatically reopen the last opened folder when the app starts"
},

"theme": {
"title": "Motyw",
"description": "Zmień motyw aplikacji"
Expand Down
5 changes: 5 additions & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@
"description": "Увеличивает толщину шрифта во всём приложении"
},

"restoreFolder": {
"title": "Восстановить последнюю папку",
"description": "Автоматически открывать последнюю папку при запуске приложения"
},

"theme": {
"title": "Тема",
"description": "Изменить тему приложения"
Expand Down
5 changes: 5 additions & 0 deletions languages/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
"description": "Збільшує товщину шрифту в усьому застосунку"
},

"restoreFolder": {
"title": "Відновити останню папку",
"description": "Автоматично відкривати останню папку при запуску застосунку"
},

"theme": {
"title": "Тема",
"description": "Змінити тему застосунку"
Expand Down