aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorEbbe Steenhoudt2021-11-14 15:12:56 +0000
committerGitHub2021-11-14 15:12:56 +0000
commitedc976b6bb36c6017bf59691abbde5c086267bfd (patch)
tree44d67559a00301fdc6e3606313f5bac1ff080d45 /helix-term/src/ui
parent1817b7f581f579232a216f92e0cac569b1a80c11 (diff)
Added workspace_symbol_picker (#1041)
* Added workspace_symbol_picker * Moved truncation of the symbol pickers to the end. * Fixed typo
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/picker.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index c44b7625..6b1c5832 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -37,6 +37,7 @@ type FileLocation = (PathBuf, Option<(usize, usize)>);
pub struct FilePicker<T> {
picker: Picker<T>,
+ pub truncate_start: bool,
/// Caches paths to documents
preview_cache: HashMap<PathBuf, CachedPreview>,
read_buffer: Vec<u8>,
@@ -90,6 +91,7 @@ impl<T> FilePicker<T> {
) -> 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),
@@ -172,6 +174,7 @@ impl<T: 'static> Component for FilePicker<T> {
};
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 {
@@ -277,6 +280,8 @@ pub struct Picker<T> {
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<dyn Fn(&T) -> Cow<str>>,
callback_fn: Box<dyn Fn(&mut Editor, &T, Action)>,
@@ -306,6 +311,7 @@ impl<T> Picker<T> {
cursor: 0,
prompt,
render_centered,
+ truncate_start: true,
format_fn: Box::new(format_fn),
callback_fn: Box::new(callback_fn),
};
@@ -521,7 +527,7 @@ impl<T: 'static> Component for Picker<T> {
text_style
},
true,
- true,
+ self.truncate_start,
);
}
}