mirror of https://github.com/helix-editor/helix
Use existing `impl` for helper function
parent
9c0f960ad4
commit
3b944bb947
|
@ -985,6 +985,15 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_layout(&self, area: Rect) -> (bool, bool) {
|
||||
let render_preview = self.show_preview
|
||||
&& self.file_fn.is_some()
|
||||
&& area.width >= MIN_AREA_WIDTH_FOR_PREVIEW
|
||||
&& area.height >= MIN_AREA_HEIGHT_FOR_PREVIEW;
|
||||
let stack_vertically = area.width / 2 < MIN_AREA_WIDTH_FOR_PREVIEW;
|
||||
(render_preview, stack_vertically)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I, D> {
|
||||
|
@ -1009,7 +1018,7 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
|
|||
// | |
|
||||
// +---------+
|
||||
|
||||
let (render_preview, stack_vertically) = self.get_picker_layout(area);
|
||||
let (render_preview, stack_vertically) = self.get_layout(area);
|
||||
let picker_area = if render_preview {
|
||||
if stack_vertically {
|
||||
area.with_height(area.height / 3)
|
||||
|
@ -1153,7 +1162,7 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
|
|||
// calculate the inner area inside the box
|
||||
let inner = block.inner(area);
|
||||
|
||||
let (render_preview, stack_vertically) = self.get_picker_layout(area);
|
||||
let (render_preview, stack_vertically) = self.get_layout(area);
|
||||
let picker_width = if render_preview && !stack_vertically {
|
||||
area.width / 2
|
||||
} else {
|
||||
|
@ -1179,15 +1188,5 @@ impl<T: 'static + Send + Sync, D> Drop for Picker<T, D> {
|
|||
self.version.fetch_add(1, atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
impl<T: 'static + Send + Sync, D> Picker<T, D> {
|
||||
fn get_picker_layout(&self, area: Rect) -> (bool, bool) {
|
||||
let render_preview = self.show_preview
|
||||
&& self.file_fn.is_some()
|
||||
&& area.width >= MIN_AREA_WIDTH_FOR_PREVIEW
|
||||
&& area.height >= MIN_AREA_HEIGHT_FOR_PREVIEW;
|
||||
let stack_vertically = area.width / 2 < MIN_AREA_WIDTH_FOR_PREVIEW;
|
||||
(render_preview, stack_vertically)
|
||||
}
|
||||
}
|
||||
|
||||
type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
|
||||
|
|
Loading…
Reference in New Issue