diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index bd450c689f304..e025a27d04c44 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2685,7 +2685,7 @@ fn symbol_picker(cx: &mut Context) { } }; - let picker = FilePicker::new( + let mut picker = FilePicker::new( symbols, |symbol| (&symbol.name).into(), move |editor: &mut Editor, symbol, _action| { @@ -2710,6 +2710,7 @@ fn symbol_picker(cx: &mut Context) { Some((path, line)) }, ); + picker.truncate_start = false; compositor.push(Box::new(picker)) } }, @@ -2734,7 +2735,7 @@ fn workspace_symbol_picker(cx: &mut Context) { compositor: &mut Compositor, response: Option>| { if let Some(symbols) = response { - let picker = FilePicker::new( + let mut picker = FilePicker::new( symbols, move |symbol| { let path = symbol.location.uri.to_file_path().unwrap(); @@ -2771,6 +2772,7 @@ fn workspace_symbol_picker(cx: &mut Context) { Some((path, line)) }, ); + picker.truncate_start = false; compositor.push(Box::new(picker)) } }, diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index d6807e317467c..0fc67a346f101 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -569,7 +569,7 @@ impl Default for Keymaps { "f" => file_picker, "b" => buffer_picker, "s" => symbol_picker, - "t" => workspace_symbol_picker, + "S" => workspace_symbol_picker, "a" => code_action, "'" => last_picker, "w" => { "Window" diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 291f1f856b433..92a84b844187b 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -36,6 +36,7 @@ type FileLocation = (PathBuf, Option<(usize, usize)>); pub struct FilePicker { picker: Picker, + pub truncate_start: bool, /// Caches paths to documents preview_cache: HashMap, read_buffer: Vec, @@ -89,6 +90,7 @@ impl FilePicker { ) -> Self { Self { picker: Picker::new(false, options, format_fn, callback_fn), + truncate_start: true, preview_cache: HashMap::new(), read_buffer: Vec::with_capacity(1024), file_fn: Box::new(preview_fn), @@ -171,6 +173,7 @@ impl Component for FilePicker { }; let picker_area = area.with_width(picker_width); + self.picker.truncate_start = self.truncate_start; self.picker.render(picker_area, surface, cx); if !render_preview { @@ -276,6 +279,8 @@ pub struct Picker { prompt: Prompt, /// Whether to render in the middle of the area render_centered: bool, + /// Wheather to truncate the start (default true) + pub truncate_start: bool, format_fn: Box Cow>, callback_fn: Box, @@ -305,6 +310,7 @@ impl Picker { cursor: 0, prompt, render_centered, + truncate_start: true, format_fn: Box::new(format_fn), callback_fn: Box::new(callback_fn), }; @@ -566,7 +572,7 @@ impl Component for Picker { text_style }, true, - true, + self.truncate_start, ); } }