aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-27 04:59:49 +0000
committerBlaž Hrastnik2022-03-28 02:02:49 +0000
commit4940db3e2de21b47a7f867896befbcc5010d231d (patch)
tree0410ce2d4782b444a009e8818dbffb50c577849e /helix-term/src/ui
parent20cf75dfa1097988cb66dbd5696154584ae32e4b (diff)
Make truncate_start a builder method instead
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/picker.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index a1a22c71..42c42284 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -91,15 +91,25 @@ impl<T> FilePicker<T> {
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
preview_fn: impl Fn(&Editor, &T) -> Option<FileLocation> + 'static,
) -> Self {
+ let truncate_start = true;
+ let mut picker = Picker::new(options, format_fn, callback_fn);
+ picker.truncate_start = truncate_start;
+
Self {
- picker: Picker::new(options, format_fn, callback_fn),
- truncate_start: true,
+ picker,
+ truncate_start,
preview_cache: HashMap::new(),
read_buffer: Vec::with_capacity(1024),
file_fn: Box::new(preview_fn),
}
}
+ pub fn truncate_start(mut self, truncate_start: bool) -> Self {
+ self.truncate_start = truncate_start;
+ self.picker.truncate_start = truncate_start;
+ self
+ }
+
fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
self.picker
.selection()
@@ -176,7 +186,6 @@ 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 {