focus-editor / focus

A simple and fast text editor
GNU General Public License v3.0
1.81k stars 99 forks source link

Config versioning #448

Closed onelivesleft closed 1 month ago

onelivesleft commented 1 month ago

This adds some auditing to changes in config settings, to try and keep the config_migrator up to date. I started working on the Settings struct first, and came up with something fairly robust, then moved on to Color and Keymap, where I found I couldn't take the same approach and so they are not so great :/

Settings

Each settings member is now required to be annotated with a version indicator (@v7 for instance). If someone adds a setting they will be prompted to do this. This version is then checked against the ADDED_SETTINGS and RENAMED_SETTINGS arrays in the migrator, making sure they are kept up to date.

Colors

Seems like jai does not yet support annotating individual enum members. So, for the colors array we just check if there are more colors than we expect, and if there are tell the programmer to add the new color to ADDED_COLORS or RENAMED_COLORS.

Keymaps

For migrator purposes not all new keybinds are necessary: only keybinds which have a default should be included. Therefor, we check for new keybinds in the default config, and if we find them we prompt the programmer to update ADDED_KEYBINDS or RENAMED_KEYBINDS.