SublimeText/TrailingSpaces — pull request #45 by geoffstokes (2013-04-12 04:24:00+00:00)
Title: Proposed fix for crash on first load

Fixes SublimeText/TrailingSpaces/issues/41 and SublimeText/TrailingSpaces/issues/38

This employs the same technique used by other default values, defining a `DEFAULT_REGEXP` and utilising that as the default.

It appears that the `plugin_loaded` call can occur before the `trailing_spaces.sublime-settings` file is copied into the plugin directory, meaning that Sublime loads an empty settings object.

You can reproduce this behaviour by removing the plug in, and then manually copying the settings file into the folder before copying the plugin's python file. If performed in this order, the settings load correctly.

This patch has only been tested in Sublime Text 2, however, it uses techniques which are already used throughout the plug-in and work just fine in ST3.

If this is not satisfactory, it may be possible to rename `trailing_spaces.sublime-settings` to a file name which occurs "before" `trailing_spaces.py`, to change the order in which the files are written to disk, however this would have the disadvantage of invalidating all users' existing preferences.