EasyClangComplete icon indicating copy to clipboard operation
EasyClangComplete copied to clipboard

Reload settings if project file has changed

Open bigboze opened this issue 9 years ago • 6 comments

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.

bigboze avatar Jun 06 '17 13:06 bigboze

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.

niosus avatar Jun 06 '17 13:06 niosus

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.

  1. Add command that allows me to force reload the settings.
  2. 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. :)

bigboze avatar Jun 06 '17 21:06 bigboze

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.

niosus avatar Jun 07 '17 08:06 niosus

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.

niosus avatar Jul 02 '17 12:07 niosus

Just received the update when reloading sublime text for exactly this reason. Thank you so much for getting round to this! 👍

bigboze avatar Jul 05 '17 10:07 bigboze

Sure thing! Tell me if something is not working as expected.

niosus avatar Jul 05 '17 14:07 niosus