on master help sign in
global search: show file names as relative paths (#802)
4a92a79Dylan Richardson
helix-term/src/commands.rs+8−1
@@ -1291,6 +1291,7 @@ fn global_search(cx: &mut Context) {
1291
1291
1292 cx.push_layer(Box::new(prompt));
1292 cx.push_layer(Box::new(prompt));
1293
1293
1294+ let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
1294 let show_picker = async move {
1295 let show_picker = async move {
1295 let all_matches: Vec<(usize, PathBuf)> =
1296 let all_matches: Vec<(usize, PathBuf)> =
1296 UnboundedReceiverStream::new(all_matches_rx).collect().await;
1297 UnboundedReceiverStream::new(all_matches_rx).collect().await;
@@ -1302,7 +1303,13 @@ fn global_search(cx: &mut Context) {
1302 }
1303 }
1303 let picker = FilePicker::new(
1304 let picker = FilePicker::new(
1304 all_matches,
1305 all_matches,
1305− move |(_line_num, path)| path.to_str().unwrap().into(),
1306+ move |(_line_num, path)| {
1307+ path.strip_prefix(&root)
1308+ .unwrap_or(path)
1309+ .to_str()
1310+ .unwrap()
1311+ .into()
1312+ },
1306 move |editor: &mut Editor, (line_num, path), action| {
1313 move |editor: &mut Editor, (line_num, path), action| {
1307 match editor.open(path.into(), action) {
1314 match editor.open(path.into(), action) {
1308 Ok(_) => {}
1315 Ok(_) => {}