diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-11 15:22:17 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-11 15:22:17 -0400 |
commit | d9a4d91a6b00691d4b363edeb2623ccc8d1f1d55 (patch) | |
tree | 1cc764aa7afec97d1d7f4d983f075b0c2ebd95ac /src/ui | |
parent | c23a09814d861b0e7deee7d331fdb3c97deffb4b (diff) |
remove window module and fix unwrap none when opening file
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_dirlist_detailed.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 0fffd79..e0e580c 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -33,13 +33,15 @@ impl<'a> Widget for TuiDirListDetailed<'a> { let y = area.top(); let dir_len = self.dirlist.contents.len(); - if dir_len == 0 { - let style = Style::default().bg(Color::Red).fg(Color::White); - buf.set_stringn(x, y, "empty", area.width as usize, style); - return; - } + let curr_index = match self.dirlist.index { + Some(i) => i, + None => { + let style = Style::default().bg(Color::Red).fg(Color::White); + buf.set_stringn(x, y, "empty", area.width as usize, style); + return; + } + }; - let curr_index = self.dirlist.index.unwrap(); let skip_dist = curr_index / area.height as usize * area.height as usize; let screen_index = if skip_dist > 0 { |