Skip to content

Commit

Permalink
fix(file-tree): adjust to breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usagi-flow committed May 18, 2024
1 parent eec324d commit 2adce35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn FnOnce(&mut Compositor, &mut compositor::Context<'_>)>> =
Vec::with_capacity(1);

callbacks.push(Box::new(
|compositor: &mut Compositor, cx: &mut compositor::Context| {
if let Some(editor) = compositor.find::<ui::EditorView>() {
match editor.explorer.as_mut() {
Expand All @@ -2918,10 +2921,15 @@ fn open_or_focus_explorer(cx: &mut Context) {
}
},
));

cx.callback = callbacks;
}

fn reveal_file(cx: &mut Context, path: Option<PathBuf>) {
cx.callback = Some(Box::new(
let mut callbacks: Vec<Box<dyn FnOnce(&mut Compositor, &mut compositor::Context<'_>)>> =
Vec::with_capacity(1);

callbacks.push(Box::new(
|compositor: &mut Compositor, cx: &mut compositor::Context| {
if let Some(editor) = compositor.find::<ui::EditorView>() {
(|| match editor.explorer.as_mut() {
Expand All @@ -2941,6 +2949,8 @@ fn reveal_file(cx: &mut Context, path: Option<PathBuf>) {
}
},
));

cx.callback = callbacks;
}

fn reveal_current_file(cx: &mut Context) {
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/ui/explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand All @@ -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)
Expand Down

0 comments on commit 2adce35

Please sign in to comment.