on master help sign in
goto_file_impl: use relative path to open file (#7965)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commit0cc94cd87a7db287a617b60b0a3f444362cf173c authorMike <62124625+michaelBelsanti@users.noreply.github.com> dateMon 21 Aug 2023, 12:15 (3 years ago) parent7534296
1 file changed+5−1
helix-term/src/commands.rs+5−1
helix-term/src/commands.rs+5−1
@@ -1160,6 +1160,10 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
11601160 let (view, doc) = current_ref!(cx.editor);
11611161 let text = doc.text();
11621162 let selections = doc.selection(view.id);
1163+ let rel_path = doc
1164+ .relative_path()
1165+ .map(|path| path.parent().unwrap().to_path_buf())
1166+ .unwrap_or_default();
11631167 let mut paths: Vec<_> = selections
11641168 .iter()
11651169 .map(|r| text.slice(r.from()..r.to()).to_string())
@@ -1190,7 +1194,7 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
11901194 for sel in paths {
11911195 let p = sel.trim();
11921196 if !p.is_empty() {
1193− let path = Path::new(p);
1197+ let path = &rel_path.join(p);
11941198 if path.is_dir() {
11951199 let picker = ui::file_picker(path.into(), &cx.editor.config());
11961200 cx.push_layer(Box::new(overlaid(picker)));