From 2adce35bd71f24a4c4b3cab62e175a7df6de43b4 Mon Sep 17 00:00:00 2001 From: etienne-k <2804556+etienne-k@users.noreply.github.com> Date: Sat, 18 May 2024 22:35:09 +0200 Subject: [PATCH] fix(file-tree): adjust to breaking changes --- helix-term/src/commands.rs | 14 ++++++++++++-- helix-term/src/ui/explorer.rs | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 911dbe256..96c30075d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2905,7 +2905,10 @@ fn file_picker_in_current_directory(cx: &mut Context) { } fn open_or_focus_explorer(cx: &mut Context) { - cx.callback = Some(Box::new( + let mut callbacks: Vec)>> = + Vec::with_capacity(1); + + callbacks.push(Box::new( |compositor: &mut Compositor, cx: &mut compositor::Context| { if let Some(editor) = compositor.find::() { match editor.explorer.as_mut() { @@ -2918,10 +2921,15 @@ fn open_or_focus_explorer(cx: &mut Context) { } }, )); + + cx.callback = callbacks; } fn reveal_file(cx: &mut Context, path: Option) { - cx.callback = Some(Box::new( + let mut callbacks: Vec)>> = + Vec::with_capacity(1); + + callbacks.push(Box::new( |compositor: &mut Compositor, cx: &mut compositor::Context| { if let Some(editor) = compositor.find::() { (|| match editor.explorer.as_mut() { @@ -2941,6 +2949,8 @@ fn reveal_file(cx: &mut Context, path: Option) { } }, )); + + cx.callback = callbacks; } fn reveal_current_file(cx: &mut Context) { diff --git a/helix-term/src/ui/explorer.rs b/helix-term/src/ui/explorer.rs index 4ad8dee72..b5f1c786b 100644 --- a/helix-term/src/ui/explorer.rs +++ b/helix-term/src/ui/explorer.rs @@ -566,7 +566,7 @@ impl Explorer { } fn new_file(&mut self, path: &str) -> Result<()> { - let path = helix_core::path::get_normalized_path(&PathBuf::from(path)); + let path = helix_stdx::path::normalize(&PathBuf::from(path)); if let Some(parent) = path.parent() { std::fs::create_dir_all(parent)?; } @@ -577,7 +577,7 @@ impl Explorer { } fn new_folder(&mut self, path: &str) -> Result<()> { - let path = helix_core::path::get_normalized_path(&PathBuf::from(path)); + let path = helix_stdx::path::normalize(&PathBuf::from(path)); std::fs::create_dir_all(&path)?; self.tree.refresh()?; self.reveal_file(path)