Merge entries within the 'commands' config#29
Merged
dzfrias merged 1 commit intodzfrias:mainfrom Sep 29, 2023
Merged
Conversation
…tiple config files. With this change, if you have a `~/.config/projectable/config.toml` file that contains... ``` [commands] "ctrl-t" = "echo hey there" "ctrl-y" = "echo this is a demo" ``` and then a `$PWD/.projectable.toml` file that contains... ``` [commands] "ctrl-t" = "echo this is replaced" "ctrl-u" = "echo this is another command" ``` Then when you run `prj` in that `$PWD` (or below), you'll get three commands: one for `ctrl-t`, one for `ctrl-y`, and one for `ctrl-u`. The command bound to `ctrl-t` will be the one that in this example says "replaced". Previously, the whole command map was getting replaced, which meant in this scenario you'd only end up with `ctrl-t` and `ctrl-u` (the `ctrl-y` command from the parent config just got discarded). I suppose this could be considered a breaking change, but for me, it's what I expected when I first read the docs about the built-in configuration merging, so hopefully it's not too spicy :)
Contributor
Author
|
(It's a very tiny diff, because all that was needed is to switch to using the HashMap merge function instead of the merge macro that only looks at the whole value non-recursively.) |
Owner
|
Thanks for the PR! Yeah, I'd definitely say that this behavior makes more sense when looking at config merging as a whole. |
dzfrias
approved these changes
Sep 29, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge entries in the 'commands' config when loading multiple files (rather than replacing it / dropping existing entries).
With this change, if you have a
~/.config/projectable/config.tomlfile that contains...and then a
$PWD/.projectable.tomlfile that contains...Then when you run
prjin that$PWD(or below), you'll get three commands: one forctrl-t, one forctrl-y, and one forctrl-u. The command bound toctrl-twill be the one that in this example says "replaced".Previously, the whole command map was getting replaced, which meant in this scenario you'd only end up with
ctrl-tandctrl-u(thectrl-ycommand from the parent config just got discarded).I suppose this could be considered a breaking change, but for me, it's what I expected when I first read the docs about the built-in configuration merging, so hopefully it's inline with the intentions of the project :)