-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
How to use imports to inherit settings, then override values (like default_flags)? #579
Comments
When file A imports file B, the settings of file B override the ones of file A. Here are two solutions I see for your problem: Solution 1: remove the This way the setings you put in Solution 2: give the two files to You can specify several paths, and they're applied in order. So you could launch broot with
Please confirm this solves your problem. |
I would expect later settings in a file to override earlier imports, and it doesn't seem true in the case of verbs, where the select-folder assignments for the Enter key do seem to override the common setting for Enter. |
There's no order among root properties of a file. Changing the position of the imports in a file changes nothing. It's not an include. |
Ok but why is the verb set for Enter in select-folder already overriding that in the imported conf? |
There's no "overriding" for verbs. It's a list. When executing a key shortcut, or looking for the verb matching a command, all verbs are tried in order until one of them matches (the built-in verbs are "loaded" after the configuration verbs). |
I have Enter defined in both. So is this right? When importing:
|
Oh I'm not at a computer but if it makes a difference that other Enter definition may be in a file imported by the common conf. |
At the macro level, you have to understand the order of file reading:
When a file is "read":
This is all defined in this simple function: https://github.com/Canop/broot/blob/master/src/conf/conf.rs#L166-L186 |
But your description of the sequence when a file is "read" does not apply when providing configs as I've now fixed the behavior with the setup in this (recently edited) comment. I stopped using imports for this purpose, and need to put the small specific configs like I guess you're saying that list is an application order, which is not the same as the read order? |
I'm sorry, I'm still confused about this. Without using imports, if I have a conf for a specific task which I want to override settings of a general conf, I can specify:
In this case the verbs/bindings will be correct, but the default_flags will be wrong. Or
In this case the verbs/bindings will be wrong, but the default_flags will be correct. |
I think the best solution for me for now is to use
and in |
I'm creating an issue for this question, as requested at #152 (comment).
I have a general/common broot config file (
conf.hjson
), and then some smaller configs that I'd like to apply on top during some invocations, adding and/or replacing values fromconf.hjson
.For example, sometimes I want to use broot to select a folder to
cd
into (in the shell), and in that case I only want to see folders, not files.conf.hjson
includesdefault_flags: igs
. I then haveselect-folder.hjson
:I invoke broot with this config in Zsh by hitting
alt
+down
, and the following Zsh loaded:I am surprised by the result: files as well as folders are shown, not only folders.
How can I get the value of
default_flags
defined inselect-folder.hjson
to apply, when using imports to combine config files?The text was updated successfully, but these errors were encountered: