aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs14
-rw-r--r--helix-term/src/ui/picker.rs6
2 files changed, 16 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index f005e376..95c46a4e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1291,7 +1291,8 @@ fn global_search(cx: &mut Context) {
cx.push_layer(Box::new(prompt));
- let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
+ let current_path = doc_mut!(cx.editor).path().cloned();
+
let show_picker = async move {
let all_matches: Vec<(usize, PathBuf)> =
UnboundedReceiverStream::new(all_matches_rx).collect().await;
@@ -1301,14 +1302,19 @@ fn global_search(cx: &mut Context) {
editor.set_status("No matches found".to_string());
return;
}
+
let picker = FilePicker::new(
all_matches,
move |(_line_num, path)| {
- path.strip_prefix(&root)
- .unwrap_or(path)
+ let relative_path = helix_core::path::get_relative_path(path)
.to_str()
.unwrap()
- .into()
+ .to_owned();
+ if current_path.as_ref().map(|p| p == path).unwrap_or(false) {
+ format!("{} (*)", relative_path).into()
+ } else {
+ relative_path.into()
+ }
},
move |editor: &mut Editor, (line_num, path), action| {
match editor.open(path.into(), action) {
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index c5b90a9c..9be2a73e 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -270,12 +270,18 @@ impl<T> Picker<T> {
}
pub fn move_up(&mut self) {
+ if self.matches.is_empty() {
+ return;
+ }
let len = self.matches.len();
let pos = ((self.cursor + len.saturating_sub(1)) % len) % len;
self.cursor = pos;
}
pub fn move_down(&mut self) {
+ if self.matches.is_empty() {
+ return;
+ }
let len = self.matches.len();
let pos = (self.cursor + 1) % len;
self.cursor = pos;