Skip to content

Commit

Permalink
goto_file_impl: use relative path to open file
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelBelsanti committed Aug 16, 2023
1 parent 0a45fb4 commit 2b4a438
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = match doc.relative_path() {
Some(p) => p.parent().unwrap().to_path_buf(),
_ => Path::new("").to_path_buf(),
};
let mut paths: Vec<_> = selections
.iter()
.map(|r| text.slice(r.from()..r.to()).to_string())
Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit 2b4a438

Please sign in to comment.