Skip to content

Commit 22d293e

Browse files
SimTheVoidSimLV
authored andcommitted
Remove old tabs on session load
1 parent 4b041f0 commit 22d293e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

doc/TODO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
- Sessions
44
- [v] Save/Load sessions
5-
- [ ] Remove old tabs on session load
5+
- [V] Remove old tabs on session load
66
- [v] Store Bookmarks
77
- [ ] Store per session settings
8+
- [ ] Detach from a session (switch do default mode)
89

910
- Editor
1011
- [ ] Auto Tabs/Spaces

src/NotepadNext/SessionManager.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,19 @@ ScintillaNext *SessionManager::loadSession(MainWindow *window, QSettings &settin
287287
const int currentEditorIndex = settings.value("CurrentEditorIndex").toInt();
288288
const int size = settings.beginReadArray("OpenedFiles");
289289

290+
for (auto &editor : window->editors()) {
291+
if (editor->isFile()) {
292+
if (editor->isSavedToDisk()) {
293+
editor->close();
294+
}
295+
}
296+
else {
297+
if (!editor->modify()) {
298+
editor->close();
299+
}
300+
}
301+
}
302+
290303
// NOTE: In theory the fileTypes should determine what is loaded, however if the session fileTypes
291304
// change from the last time it was saved then it means the settings were manually altered outside of the app,
292305
// which is non-standard behavior, so just load anything in the file

0 commit comments

Comments
 (0)