-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow opening a different project #241
base: main
Are you sure you want to change the base?
Conversation
8ae1839
to
843a57e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see multiple issues here.
On the form:
- there are 2 commits together, one is the close tab that I don't want
- you are not using conventional commit
On the code itself, changing the Project
root multiple times is a bit more involved, as project settings are loaded in Project::setRoot
.
Also it will require to stop and restart the LSP clients...
I'm not sure it's super important to be able to open multiple projects. If you want to continue in this direction, go ahead, but there's more work than that.
Otherwise close the PR.
6074fe4
to
6fc4962
Compare
This was intentional because the changes in What I've done here now is duplicate the code in each PR, so they can be merged individually in any order. Whichever PR is to be merged after will have to be re-based and have its conflicts resolved. This isn't a big deal, but it's what I was trying to avoid.
Fixed.
Fixed by saving settings if settings would've been saved when closing the app, and then reloading all settings in order so everything's anew.
Done. Tho I'm not sure of how to properly test this... |
@@ -63,6 +61,13 @@ Settings::~Settings() | |||
m_instance = nullptr; | |||
} | |||
|
|||
void Settings::loadBaseSettings() | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to clear the existing settings here.
The way Settings
is done, all settings (Knut, User and Project) are mixed into the Settings::m_settings
. So if you don't clear them, it will reuse those from an old project.
You need to clear all m(settings members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadBaseSettings
calls loadKnutSettings
, which cleanly initializes m_settings by reading, parsing and assigning the contents of ":/core/settings.json". That path is for a Qt Resource, meaning we can guarantee that it'll always be present.
Instead of redundantly clearing the contents of m_settings, what I've done is add an error log and a Q_UNREACHABLE statement after ":/core/settings.json" is read, so Knut stops in the event of a regression in which the resource file goes missing.
src/core/settings.cpp
Outdated
@@ -85,6 +90,9 @@ void Settings::loadUserSettings() | |||
|
|||
void Settings::loadProjectSettings(const QString &rootDir) | |||
{ | |||
saveOnExit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably rename into saveSettings
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saveSettings
already existed, so I went with saveIfApplicable
instead.
Opening a new project closes and replaces the current project.
Saving only takes place if it's applicable.
Saving only takes place if it's applicable.
This will protect us in the event of a regression.
Opening a new project closes all files and replaces the current project.