
There is a drawback to how we currently write our migrations: For example: 1. Suppose we change one of our actions from a string to an array and rename it, then roll out the preview build: Before: `"ctrl-x": "editor::GoToPrevHunk"` Latest: `"ctrl-x": ["editor::GoToPreviousHunk", { "center_cursor": true }]` To handle this, we wrote migration `A` to convert the string to an array. 2. Now, suppose we decide to change it back to a string: - User who hasn't migrated yet on Preview: `"ctrl-x": "editor::GoToPrevHunk"` - User who has migrated on Preview: `"ctrl-x": ["editor::GoToPreviousHunk", { "center_cursor": true }]` - Latest: `"ctrl-x": "editor::GoToPreviousHunk"` To handle this, we would need to remove migration `A` and add two more migrations: - **Migration B**: `"ctrl-x": "editor::GoToPrevHunk"` -> `"ctrl-x": "editor::GoToPreviousHunk"` - **Migration C**: `"ctrl-x": ["editor::GoToPreviousHunk", { "center_cursor": true }]` -> `"ctrl-x": "editor::GoToPreviousHunk"` Nice. But over time, this keeps increasing, making it impossible to track outdated versions and handle all cases. Missing a case means users stuck on `"ctrl-x": "editor::GoToPrevHunk"` will remain there and won't be automatically migrated to the latest state. --- To fix this, we introduce versioned migrations. Instead of removing migration `A`, we simply write a new migration that takes the user to the latest version—i.e., in this case, migration `C`. - A user who hasn't migrated before will go through both migrations `A` and `C` in order. - A user who has already migrated will only go through `C`, since `A` wouldn't change anything for them. With incremental migrations, we only need to write migrations on top of the latest state (big win!), as know internally they all would be on latest state. You *must not* modify previous migrations. Always create new ones instead. This also serves as base for only prompting user to migrate, when feature reaches stable. That way, preview and stable keymap and settings are in sync. cc: @mgsloan @ConradIrwin @probably-neb Release Notes: - N/A
41 lines
1 KiB
Rust
41 lines
1 KiB
Rust
pub const SETTINGS_ROOT_KEY_VALUE_PATTERN: &str = r#"(document
|
|
(object
|
|
(pair
|
|
key: (string (string_content) @name)
|
|
value: (_)
|
|
)
|
|
)
|
|
)"#;
|
|
|
|
pub const SETTINGS_NESTED_KEY_VALUE_PATTERN: &str = r#"(document
|
|
(object
|
|
(pair
|
|
key: (string (string_content) @parent_key)
|
|
value: (object
|
|
(pair
|
|
key: (string (string_content) @setting_name)
|
|
value: (_) @setting_value
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)"#;
|
|
|
|
pub const SETTINGS_LANGUAGES_PATTERN: &str = r#"(document
|
|
(object
|
|
(pair
|
|
key: (string (string_content) @languages)
|
|
value: (object
|
|
(pair
|
|
key: (string)
|
|
value: (object
|
|
(pair
|
|
key: (string (string_content) @setting_name)
|
|
value: (_) @value
|
|
)
|
|
)
|
|
))
|
|
)
|
|
)
|
|
(#eq? @languages "languages")
|
|
)"#;
|