on master help sign in
relative paths showing active file in global search (#803)
commit9f27be429d0b4848a01876cd0eb192f2db8a830b authorEthan Frei <ethan.frei@gmail.com> dateThu 7 Oct 2021, 21:08 (5 years ago) parent2e692dc
1 file changed+10−4
helix-term/src/commands.rs+10−4
helix-term/src/commands.rs+10−4
@@ -1291,7 +1291,8 @@ fn global_search(cx: &mut Context) {
12911291
12921292 cx.push_layer(Box::new(prompt));
12931293
1294− let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
1294+ let current_path = doc_mut!(cx.editor).path().cloned();
1295+
12951296 let show_picker = async move {
12961297 let all_matches: Vec<(usize, PathBuf)> =
12971298 UnboundedReceiverStream::new(all_matches_rx).collect().await;
@@ -1301,14 +1302,19 @@ fn global_search(cx: &mut Context) {
13011302 editor.set_status("No matches found".to_string());
13021303 return;
13031304 }
1305+
13041306 let picker = FilePicker::new(
13051307 all_matches,
13061308 move |(_line_num, path)| {
1307− path.strip_prefix(&root)
1308− .unwrap_or(path)
1309+ let relative_path = helix_core::path::get_relative_path(path)
13091310 .to_str()
13101311 .unwrap()
1311− .into()
1312+ .to_owned();
1313+ if current_path.as_ref().map(|p| p == path).unwrap_or(false) {
1314+ format!("{} (*)", relative_path).into()
1315+ } else {
1316+ relative_path.into()
1317+ }
13121318 },
13131319 move |editor: &mut Editor, (line_num, path), action| {
13141320 match editor.open(path.into(), action) {