on master help sign in
goto_file: open picker if a directory is selected (#7909)
090a225Andrés Cabero
helix-term/src/commands.rs+6−1
@@ -1190,7 +1190,11 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
1190 for sel in paths {
1190 for sel in paths {
1191 let p = sel.trim();
1191 let p = sel.trim();
1192 if !p.is_empty() {
1192 if !p.is_empty() {
1193+ let path = Path::new(p);
1194+ if path.is_dir() {
1195+ let picker = ui::file_picker(path.into(), &cx.editor.config());
1196+ cx.push_layer(Box::new(overlaid(picker)));
1193− if let Err(e) = cx.editor.open(&PathBuf::from(p), action) {
1197+ } else if let Err(e) = cx.editor.open(path, action) {
1194 cx.editor.set_error(format!("Open file failed: {:?}", e));
1198 cx.editor.set_error(format!("Open file failed: {:?}", e));
1195 }
1199 }
1196 }
1200 }
@@ -2603,6 +2607,7 @@ fn file_picker_in_current_buffer_directory(cx: &mut Context) {
2603 let picker = ui::file_picker(path, &cx.editor.config());
2607 let picker = ui::file_picker(path, &cx.editor.config());
2604 cx.push_layer(Box::new(overlaid(picker)));
2608 cx.push_layer(Box::new(overlaid(picker)));
2605}
2609}
2610+
2606fn file_picker_in_current_directory(cx: &mut Context) {
2611fn file_picker_in_current_directory(cx: &mut Context) {
2607 let cwd = helix_loader::current_working_dir();
2612 let cwd = helix_loader::current_working_dir();
2608 if !cwd.exists() {
2613 if !cwd.exists() {