Sublime Forum

Reset_font_size creates block comments in Preferences.sublime-settings

#1

In Sublime Text 4, executing reset_font_size commands, alternating with the increase_font_size command, would generate block comments in Preferences.sublime-settings like below

    /*"font_size": 15,*/
    /*"font_size": 13,*/
    /*"font_size": 13,*/

This causes burden, because Preferences.sublime-settings could change when there is no actual change.

If I remember it correctly, the behavior was not like this in ST3. The previous behavior was just removing the font_size key-value pair, if any, which is the behavior that I hope for.

Moreover, when I look into the implementation of the reset_font_size command in the Default/font.py in the current ST4, there seems to be no changes:

class ResetFontSizeCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        s = sublime.load_settings("Preferences.sublime-settings")
        s.erase("font_size")

        sublime.save_settings("Preferences.sublime-settings")

Can anyone please explain the rationale for this (i.e. block commenting instead of removing)? Is this intended or can this be restored as before?

0 Likes

#2

This is how ST API and saving settings is designed to work. Erased keys are commented out to prevent their information from being lost.

0 Likes

#3

Thank you for the reply and clarification. For the reason above, to me this is not a good design, frankly.

0 Likes

#4

FYI, Build 4194 Changelog mentions

Added “default_font_size” setting

and the Command implementation looks like this:

class ResetFontSizeCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        s = sublime.load_settings("Preferences.sublime-settings")
        s.set("font_size", s.get("default_font_size", 10))

        sublime.save_settings("Preferences.sublime-settings")

1 Like

#5

Thanks for the heads-up and great to hear about this update!

Meanwhile, not related to font size setting but about the Sublime Text API of Setting.erase() - It wouldn’t be ideal to me if the previous behavior of Setting.erase() is to really erase, but the current behavior is to comment out, because changing the behavior for an API should not be recommended in the API design. I’d rather to have a new API called Setting.comment_out() or even Setting.erase2().

0 Likes