From 91e56d876d6998d2a6045d0e1e31cd36312783e7 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Sat, 23 Mar 2024 21:32:12 +0100 Subject: [PATCH] digit editor: create char repr if not available --- lib-nested-core/src/editors/digit/ctx.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib-nested-core/src/editors/digit/ctx.rs b/lib-nested-core/src/editors/digit/ctx.rs index bb022a7..8547552 100644 --- a/lib-nested-core/src/editors/digit/ctx.rs +++ b/lib-nested-core/src/editors/digit/ctx.rs @@ -39,6 +39,20 @@ pub fn init_ctx( ctx: Arc> ) { _ => 0 }; + /* get char representation or create it if not available + */ + let char_rt = + if let Some(crt) = src_rt.descend(Context::parse(&ctx, "Char")) { + crt + } else { + let crt = ReprTree::from_singleton_buffer( + Context::parse(&ctx, "Char"), + SingletonBuffer::new('\0') + ); + src_rt.insert_branch(crt.clone()); + crt + }; + /* Create EditTree object */ let mut edittree = DigitEditor::new(