diff options
author | Dylan Richardson | 2021-10-02 23:41:52 +0000 |
---|---|---|
committer | GitHub | 2021-10-02 23:41:52 +0000 |
commit | 4a92a79da44997acf3f289d530069da7f7e6dbb1 (patch) | |
tree | 8c72fa58ec2adbbf763b5b005a978faa522e0806 /helix-term | |
parent | e47632114a92dbabc2f9d41bedb455e13996924e (diff) |
global search: show file names as relative paths (#802)
This commit fixes #786
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 26f599bd..35f28212 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1291,6 +1291,7 @@ fn global_search(cx: &mut Context) { cx.push_layer(Box::new(prompt)); + let root = find_root(None).unwrap_or_else(|| PathBuf::from("./")); let show_picker = async move { let all_matches: Vec<(usize, PathBuf)> = UnboundedReceiverStream::new(all_matches_rx).collect().await; @@ -1302,7 +1303,13 @@ fn global_search(cx: &mut Context) { } let picker = FilePicker::new( all_matches, - move |(_line_num, path)| path.to_str().unwrap().into(), + move |(_line_num, path)| { + path.strip_prefix(&root) + .unwrap_or(path) + .to_str() + .unwrap() + .into() + }, move |editor: &mut Editor, (line_num, path), action| { match editor.open(path.into(), action) { Ok(_) => {} |