mtxr / SublimeText-SQLTools

SQLTools for Sublime Text 3
https://code.mteixeira.dev/SublimeText-SQLTools/
GNU General Public License v3.0
177 stars 40 forks source link

Why create empty settings file on the User folder? #144

Closed evandrocoan closed 6 years ago

evandrocoan commented 6 years ago

On the lines we can find it:

File: Data/Packages/SQLTools/SQLTools.py
665:     userSettingFile = os.path.join(sublimeUserFolder, SQLTOOLS_SETTINGS_FILE)
666:     if not os.path.isfile(userSettingFile):
667:         # create empty settings file in 'User' folder
668:         sublime.save_settings(SQLTOOLS_SETTINGS_FILE)

Above has the comment:

    # this ensures we have empty settings file in 'User' directory during first start
    # otherwise sublime will copy entire contents of 'SQLTools.sublime-settings'
    # which is not desirable and prevents future changes to queries and other
    # sensible defaults defined in settings file, as those would be overriden by content
    # from older versions of SQLTools in 'User\SQLTools.sublime-settings'

However I never saw Sublime Text doing such thing on version 3. Perhaps this is a fix Sublime Text version 2?

tkopets commented 6 years ago

This change was introduced not that long ago and I think the above-mentioned Sublime Text behavior in that comment is still valid. I believe I observed this at least on Sublime Text build 3126 - you can try to comment out or remove this line and take a look at the outcome yourself.

evandrocoan commented 5 years ago

I just tested, Sublime Text does not do that. This plugin does that:

File: Data/Packages/SQLTools/SQLToolsAPI/Storage.py
 8: class Storage:
 9:     def __init__(self, filename, default=None):
10:         self.storageFile = filename
11:         self.defaultFile = default
12:         self.items = {}
13: 
14:         # copy entire file, to keep comments
15:         if not os.path.isfile(filename) and default and os.path.isfile(default):
16:             shutil.copyfile(default, filename)