diff options
author | Mike | 2023-08-21 16:15:45 +0000 |
---|---|---|
committer | GitHub | 2023-08-21 16:15:45 +0000 |
commit | 0cc94cd87a7db287a617b60b0a3f444362cf173c (patch) | |
tree | 21223d06dd0ef2245aa872eaeca6ed5113a3075f /helix-term/src/commands.rs | |
parent | 75342968e23a56d4156a6c845517ea7491838b98 (diff) |
goto_file_impl: use relative path to open file (#7965)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 07aef95d..1f88079e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1160,6 +1160,10 @@ fn goto_file_impl(cx: &mut Context, action: Action) { let (view, doc) = current_ref!(cx.editor); let text = doc.text(); let selections = doc.selection(view.id); + let rel_path = doc + .relative_path() + .map(|path| path.parent().unwrap().to_path_buf()) + .unwrap_or_default(); let mut paths: Vec<_> = selections .iter() .map(|r| text.slice(r.from()..r.to()).to_string()) @@ -1190,7 +1194,7 @@ fn goto_file_impl(cx: &mut Context, action: Action) { for sel in paths { let p = sel.trim(); if !p.is_empty() { - let path = Path::new(p); + let path = &rel_path.join(p); if path.is_dir() { let picker = ui::file_picker(path.into(), &cx.editor.config()); cx.push_layer(Box::new(overlaid(picker))); |