@@ -173,7 +173,7 @@ impl<T: Item + 'static> Component for FilePicker<T> {
173 // | | | |
173 // | | | |
174 // +---------+ +---------+
174 // +---------+ +---------+
176− let render_preview = area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
176+ let render_preview = self.picker.show_preview && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
177 // -- Render the frame:
177 // -- Render the frame:
178 // clear area
178 // clear area
179 let background = cx.editor.theme.get("ui.background");
179 let background = cx.editor.theme.get("ui.background");
@@ -300,6 +300,8 @@ pub struct Picker<T: Item> {
300 previous_pattern: String,
300 previous_pattern: String,
301 /// Whether to truncate the start (default true)
301 /// Whether to truncate the start (default true)
302 pub truncate_start: bool,
302 pub truncate_start: bool,
303+ /// Whether to show the preview panel (default true)
304 callback_fn: Box<dyn Fn(&mut Context, &T, Action)>,
306 callback_fn: Box<dyn Fn(&mut Context, &T, Action)>,
@@ -327,6 +329,7 @@ impl<T: Item> Picker<T> {
328 previous_pattern: String::new(),
330 previous_pattern: String::new(),
329 truncate_start: true,
331 truncate_start: true,
330 callback_fn: Box::new(callback_fn),
333 callback_fn: Box::new(callback_fn),
331 completion_height: 0,
334 completion_height: 0,
@@ -470,6 +473,10 @@ impl<T: Item> Picker<T> {
470 self.filters.sort_unstable(); // used for binary search later
473 self.filters.sort_unstable(); // used for binary search later
471 self.prompt.clear(cx);
474 self.prompt.clear(cx);
477+ pub fn toggle_preview(&mut self) {
478+ self.show_preview = !self.show_preview;
475// process:
482// process:
@@ -538,6 +545,9 @@ impl<T: Item + 'static> Component for Picker<T> {
538 ctrl!(' ') => {
545 ctrl!(' ') => {
539 self.save_filter(cx);
546 self.save_filter(cx);
549+ self.toggle_preview();
542 if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
552 if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
543 // TODO: recalculate only if pattern changed
553 // TODO: recalculate only if pattern changed