SublimeText / WordHighlight

Highlight all copies of the currently selected word.
MIT License
179 stars 24 forks source link

Misinterpretation of "add_on_change" listener. #30

Closed titoBouzout closed 12 years ago

titoBouzout commented 12 years ago

Fix a misinterpretation of "add_on_change" listener.

Receives a key which will listen all the preferences instead of receiving a preference name.

adzenith commented 12 years ago

Oh interesting. Nice catch. I guess the settings API actually makes more sense this way. I didn't really think about this until I saw your Pref = Pref() line, but can you think of a reason why Pref.load() couldn't just be a classmethod? (or why load_prefs couldn't just be a classless function?)

titoBouzout commented 12 years ago

To make clear that everything coming from "Pref.something" is a global. Also, makes more easy the reload of the two different prefs files. If not you need to write two functions?

Also if Pref.load is a method of wordhighlitgh (damn spell checker ) it will reload every-time.

Not sure about more reasons, but I've written many plug-ins with this convention, and easily fixed this error on 5 of them, almost doing the same because of this "Pref" thing.

titoBouzout commented 12 years ago

I don't think the API makes more sense this way. Because there is no way to listen just 1 preference. We will reload when unrelated preferences are changed, which is non efficient.

I was thinking was this way because of my work with Firefox Extensions.

titoBouzout commented 12 years ago

ping

adzenith commented 12 years ago

Whoops! Sorry. I must have thought I'd already merged it.