-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keymap: Use snake_case for consistency #23834
base: main
Are you sure you want to change the base?
Conversation
That is a rabbit hole I had lured you in, sorry for such a large scope. Looking at this PR growing, I think we need to consider one thing (not needed to be done now, but might be needed before the PR is merged): a keymap migration tool. We do not collect users' keymaps in any form, so it's not clear how many people will suffer from this — presumably, some amount of Vim users? This are all ideas though, at this stage, thank you for providing more food for thought. |
I think the work for this PR is done. I'll open another PR to show a button in the keymap error dialog, but only if we detect it's a casing error. The button could say something like "Backup and Migrate Keymap" to make it clear what happened. I think the script for this should be fairly simple - at least, that’s what it seems like for now. |
Could we just automatically and silently migrate keymaps, while backing them up? If it's a simple find-and-replace job, it doesn't seem like something we have to bother users with. |
2 small concerns against that:
IMO, it's worth to indicate that migration had happened and show where the backup file is placed. |
@@ -725,6 +725,7 @@ impl PaneAxis { | |||
} | |||
|
|||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, JsonSchema)] | |||
#[serde(rename_all = "snake_case")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit sad that we have to do this — seems that many our code has such conversions already, but I personally see no harm in having the existing, single words in whatever case they are: this way, it will be less breakage to the keymap.
Not insisting though, as it seems not very uniform and we're breaking things anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about this a lot, and initially, I preferred not to break too many things. However, if we keep single words in camelCase, it will affect other enums that might have data like Object
in below case:
"i": ["vim::PushOperator", { "Object": { "around": false } }],
So, again inconsistency with keys. Hence, I made this difficult decision.
I don't think this is blocking, as find and replace doesn't care about errors.
I agree on both counts, and as a general rule asking before doing things is polite. |
Let me figure if simple find and replace will suffice. I strongly think it might be, just checking if there are no edge case doing so. |
If we're going to break these... For things where there are a small number of options like I added these actions before I knew that actions with arguments didn't show up in the command palette; and think it'd be better to not use that pattern going forward. Sorry! Probably similar for the ResizePane ones. For |
8db0848
to
e5b6352
Compare
Apart from flattening you suggested, I also end up doing same for PushOperator: "y": ["vim::PushOperator", "yank"], // from
"y": "vim::PushYank", // to and "f": ["vim::PushOperator", { "find_forward": { "before": false } }], // from
"f": ["vim::PushFindForward", { "before": false }], // to I also wonder, now that we are doing that, we should also: "escape": ["vim::SwitchMode", "normal"], // from
"escape": "vim::SwitchToNormalMode", // to to follow similar convention. What do you think? |
I changed it. Felt sensible. |
We are already using snake_case in bunch of places for action properties in keymap, but along with it their are few occurances of cameCase as well as PascalCase.
This PR converts following into snake_case, so that it's consistent across:
Release Notes:
snake_case
. If you've configured a custom keymap, you might need to update it manually.