diff options
author | qkzk <qu3nt1n@gmail.com> | 2022-11-30 21:34:56 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2022-11-30 21:34:56 +0100 |
commit | 0b2ebab60ac59eeacdae4d05220e44e45ba499e0 (patch) | |
tree | f1d3e6ab1f1867032eda5d85ca72609c8b4515da | |
parent | b6d641b97b47ed51eedcab175d77b3bd45548f52 (diff) |
Prevent preview of non normal files
-rw-r--r-- | src/tab.rs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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(()) } |