Sublime Forum

Reset_font_size removing font_size from settings

#1

I have Ctrl+0 set to reset_font_size and also have font_size in my preferences (set as 8, compared to the default of 10). Problem is, and I’ve got this on both my Windows install and my Linux, that when I press Ctrl+0 the font_size is removed from my settings and it resets to 10.

Is this a known issue or am I using reset_font_size incorrectly?

1 Like

#2

I can confirm that you are not using the command incorrectly. It is implemented in Packages/Default/font.py as:

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")

which shows that this seems to be the intended behavior. I recommend changing it (using https://packagecontrol.io/packages/PackageResourceViewer) to accept a font_size argument like:

class ResetFontSizeCommand(sublime_plugin.ApplicationCommand):
    def run(self, font_size = None):
        s = sublime.load_settings("Preferences.sublime-settings")
        if not font_size:
            s.erase("font_size")
        else:
            s.set('font_size', font_size)

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

so that you can add your desired font size to your keybinding.

0 Likes

#3

Surely the whole point of preferences is that we should be able to use the preference that’s set and that is the font_size it gets reverted to?? I didn’t look at the font.py but that definitely seems a bit weird, why would you even have an option to use font_size if it just goes and replaces it…

Perhaps there’s another function for “reset to the font_size in my settings”…?

0 Likes

#4

the way it is designed, when you change the font size through the Preferences -> Font menu, it updates the value of font_size in your preferences… so there is nothing to reset back to.

How it arguably should work (at least with the Ctrl mouse scroll wheel bindings imo), would be to affect only the current tab - see the following post for such an implementation:

0 Likes

#5

The problem is that even using the Font menu, it always reverts back to font_size of 10 - there’s seems to be no way, that I can see, to have my font size as 8.

I’m always showing people, that need larger font, things on my screen and I then want to revert back to my size 8 font but the only way I can do this seems to be to Ctrl+= many times.

I can see how the Ctrl+=/- is working now, by updating my preferences, but this isn’t ideal for how I work (and surely I’m not the only person to have colleagues with not such great eyesight lol)

0 Likes

#6

except with my plugin override suggestion and setting your desired font size in the menu and keybinding

0 Likes

#7

Works, just not very portable :wink: also, presumably, when I reinstall/upgrade Sublime it’ll then need to be set again.

I might just have to make this a custom plugin I guess…

0 Likes

#8

reinstalling ST doesn’t affect your preferences/overrides, nor does upgrading. So it may be wise to install https://packagecontrol.io/packages/OverrideAudit to be notified when your override is out of date

see also

0 Likes

#9

Hmm OK, that works. Thanks :slight_smile:

0 Likes

#10

https://packagecontrol.io/packages/RevertFontSize

1 Like