summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-11-30 21:34:56 +0100
committerqkzk <qu3nt1n@gmail.com>2022-11-30 21:34:56 +0100
commit0b2ebab60ac59eeacdae4d05220e44e45ba499e0 (patch)
treef1d3e6ab1f1867032eda5d85ca72609c8b4515da
parentb6d641b97b47ed51eedcab175d77b3bd45548f52 (diff)
Prevent preview of non normal files
-rw-r--r--src/tab.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tab.rs b/src/tab.rs
index de96f564..430b9776 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -309,10 +309,14 @@ impl Tab {
pub fn event_preview(&mut self) -> FmResult<()> {
if self.path_content.files.is_empty() {
return Err(FmError::new("No file to preview"));
- };
- self.mode = Mode::Preview;
- self.preview = Preview::new(&self.path_content)?;
- self.window.reset(self.preview.len());
+ }
+ if let Some(file) = self.path_content.selected_file() {
+ if let FileKind::NormalFile = file.file_kind {
+ self.mode = Mode::Preview;
+ self.preview = Preview::new(&self.path_content)?;
+ self.window.reset(self.preview.len());
+ }
+ }
Ok(())
}