diff options
-rw-r--r-- | pkgs/by-name/lf/lf-make-map/Cargo.lock | 3 | ||||
-rw-r--r-- | pkgs/by-name/lf/lf-make-map/src/mapping/mod.rs | 18 |
2 files changed, 16 insertions, 5 deletions
diff --git a/pkgs/by-name/lf/lf-make-map/Cargo.lock b/pkgs/by-name/lf/lf-make-map/Cargo.lock index 20779f60..51cbf6ad 100644 --- a/pkgs/by-name/lf/lf-make-map/Cargo.lock +++ b/pkgs/by-name/lf/lf-make-map/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. # nixos-config - My current NixOS configuration # # Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> @@ -7,7 +9,6 @@ # # You should have received a copy of the License along with this program. # If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. - version = 4 [[package]] diff --git a/pkgs/by-name/lf/lf-make-map/src/mapping/mod.rs b/pkgs/by-name/lf/lf-make-map/src/mapping/mod.rs index a5f94067..21392388 100644 --- a/pkgs/by-name/lf/lf-make-map/src/mapping/mod.rs +++ b/pkgs/by-name/lf/lf-make-map/src/mapping/mod.rs @@ -10,7 +10,7 @@ use anyhow::Result; use keymaps::map_tree::{Node, Trie}; -use log::{debug, log_enabled, trace, Level}; +use log::{Level, debug, log_enabled, trace}; use map_key::MapKey; pub mod lf_mapping; @@ -130,7 +130,7 @@ impl MappingsTrie { { let mut full_foreign_keys = parent_keys.to_vec(); full_foreign_keys.append(&mut foreign_keys); - self.0.insert_node(&full_foreign_keys, &other_node)?; + self.insert_node(&full_foreign_keys, other_node)?; } } } @@ -138,13 +138,13 @@ impl MappingsTrie { { let mut full_our_keys = parent_keys.to_vec(); full_our_keys.append(&mut our_keys); - self.0.insert_node(&full_our_keys, &node)?; + self.insert_node(&full_our_keys, node)?; } Ok(()) } keymaps::error::TrieInsert::KeyIncludesChild { - mut child_key, + child_key: key, child_value, } => { // A node that should be a parent was classified @@ -154,6 +154,16 @@ impl MappingsTrie { // 2. Add the child node to the parent node as child, but with a '.' as MapKey. // 3. Add the original node also as child to the parent node. + assert_eq!(key, keys); + + let (fetched_child_value, mut child_key) = self.0.try_get(keys); + assert_eq!(fetched_child_value.value(), Some(&child_value)); + + trace!( + "Replacing child ('{}') with a parent, so that we can continue from this point.", + MapKey::display(&child_key) + ); + let child = self .0 .replace_node(&child_key, Node::new_parent()) |