Skip to content

Commit

Permalink
Remove old tabs on session load
Browse files Browse the repository at this point in the history
  • Loading branch information
SimTheVoid authored and SimLV committed May 6, 2024
1 parent 4b041f0 commit 22d293e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

- Sessions
- [v] Save/Load sessions
- [ ] Remove old tabs on session load
- [V] Remove old tabs on session load
- [v] Store Bookmarks
- [ ] Store per session settings
- [ ] Detach from a session (switch do default mode)

- Editor
- [ ] Auto Tabs/Spaces
Expand Down
13 changes: 13 additions & 0 deletions src/NotepadNext/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ ScintillaNext *SessionManager::loadSession(MainWindow *window, QSettings &settin
const int currentEditorIndex = settings.value("CurrentEditorIndex").toInt();
const int size = settings.beginReadArray("OpenedFiles");

for (auto &editor : window->editors()) {
if (editor->isFile()) {
if (editor->isSavedToDisk()) {
editor->close();
}
}
else {
if (!editor->modify()) {
editor->close();
}
}
}

// NOTE: In theory the fileTypes should determine what is loaded, however if the session fileTypes
// change from the last time it was saved then it means the settings were manually altered outside of the app,
// which is non-standard behavior, so just load anything in the file
Expand Down

0 comments on commit 22d293e

Please sign in to comment.