SublimeText / sublime_lib

Utility library for frequently used functionality in Sublime Text and convenience functions or classes
https://sublimetext.github.io/sublime_lib
MIT License
52 stars 4 forks source link

Fix a bug when changing settings in a subscribe callback. #152

Closed Thom1729 closed 3 years ago

Thom1729 commented 3 years ago

Before this change, the saved value of a setting wasn't updated until after the callback was completed, so if you changed that settings object inside the callback, it would incorrectly detect that the first setting had changed again.

FichteFoll commented 3 years ago

This fixes an error case, but I still see potential for confusion when a "complex" object is constructed by the selector and modified in place, since the callback is called by reference, but that is a slightly different issue. To tackle that, we'd probably need a mutex and a second call of the selector to ensure we get two copies of the same state without relying on the data to be copyable, which is definitely not ideal.

Besides, I don't think it is currently documented that the selector's result must be equatable.

Thom1729 commented 3 years ago

That's a good point. I think it could be handled separately from this bug, though.