Reload settings if project file has changed
I am currently dealing with multiple build projects, so I have added ecc_common_flags to my sublime-project files which differ Among projects. When I update this file, the settings don't appear to get reloaded. Looking at the SettingsManager, only changes to EasyClangComplete.sublime-settings cause the settings to be updated.
This is non-trivial to implement as sublime text generates a callback when we change any settings. However, sublime text will not trigger a callback if we change the project settings. This forces us to handle it manually, which I avoided to this point. We could theoretically add a check of file modification of a project settings file. This part is easy. The hard part is to find which file did the user really modify in case there are multiple project files in the project folder.
Hmmm I see. having a watch on the project file or the .clang_complete isn't trivial at all, maybe checking the filemod time of the project file/.clang_complete on a view change? we should be able to query the project of the window.
Other ideas.
- Add command that allows me to force reload the settings.
- Usually I make the project changes in sublime, so maybe we can check the filename matches the project file when a save has been made using on_pre_save_async(view)?
I really don't know the API, or how plugins work well enough to judge if any of these ideas are workable. :)
Actually, adding a watch should not be that hard. We already do that for deciding when to rerun cmake and such. It won't do a callback of course, but we can check it on file focus. It shouldn't even be too hard.
You are right, I guess we can get the current project file from sublime text itself and then we'll just need to make sure it was modified since the last load.
I am pretty sure, that the flags in .clang_complete file are already treated that way. We will reload them if the file has changed. But I have to find some more time to actually look through this and confirm that it actually works.
Ok, it is definitely already implemented for .clang_complete files in this line. It is not implemented for project specific settings file. So I have changed the name of this issue accordingly.
Just received the update when reloading sublime text for exactly this reason. Thank you so much for getting round to this! 👍
Sure thing! Tell me if something is not working as expected.